I’m using a modified version of this script to back up my site’s database. I also want to back up my site’s content to DropBox as well. How can I modify the below PHP script to do this task? I’ll then set it to run as a Cron job.
$dropbox_email='myEmail'; //Dropbox username
$dropbox_pass='myPassword'; // Dropbox password
$dropbox_dir='/SITE-BACKUPS';
$backupfile = $dbname . date("Y-m-dTh:i:s") . '.sql.gz';
$backupdir = dirname(__FILE__);
system("mysqldump -h $dbhost -u $dbuser --password='$dbpass' $dbname |
gzip > $backupfile");
include("DropboxUploader.php");
$uploader = new DropboxUploader($dropbox_email, $dropbox_pass);
$uploader->upload($backupdir.'/'.$backupfile,$dropbox_dir);
unlink($backupfile);
It depends on what you mean your site’s content. If you simply want to get everything in the document root of your webserver, you would replace the system command with something like this:
where you define
$siteroot = "/var/www/html";or whatever your document root is, and