Server Backup to Dropbox with PHP – Curl – Dropbox API – Cron

By Clain Dsilva May 6, 2016
Server Backup to Dropbox

Here is the easiest way to backup your web server with Drobox.Most of you guys have trouble setting up a secure backup option, Backing up the files to the same saver where it is hosted is again not a reliable option, You may also have space constrains. Lets see how dropbox can sort out the backup easily.

  • Cpanel Access to your Server and Cron Job Module
  • Dropbox Api
  • PHP and Curl Support in the server you are going to implement this.

Lets divide the entire backup process into 3 functions

  1. Backu Database
  2. Backup files
  3. Upload it to dropbox.

Backup Database

There are hundreds of database backup scripts available in the Internet, you can use any of them but here I am going to use this code that I feel is more reliable and its taken from David Walsh’s blog I have slightly modified the script to optimize it

Backup Server Files

Lets assume that you have your files under /home/YourPath/public_html/

We are just selecting all the files under the public_html folder and creating an archive.

Drobox API Code for Backup

Now lets create the dropbox function to upload the files to dropbox

Now Lets conclude to get the Final Code

Final Code

Setting up the Cron Job

  1. Lets name the script that you have created as “serverBackupDropbox.php”
  2. Create a folder outside your public_html folder , lets name it “backup” and place the backup script inside this folder. lets assume that the file path is now “php home/backup/serverBackupDropbox.php”
  3. Navigate to Cron module in your Cpanel and add the following command, and set your desired Cron interval.

You quick and easy drop-box backup solution is ready.

Hope you have enjoyed Post , Send in your feedbacks / comments.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
Server Backup to Dropbox with PHP - Curl - Dropbox API - Cron, 5.0 out of 5 based on 1 rating

Leave a Reply

Your email address will not be published. Required fields are marked *