Created
June 9, 2014 14:52
-
-
Save legenderrys/1e8351e377e85e278f55 to your computer and use it in GitHub Desktop.
Back up DB to Dropbox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Set the timezone so filenames are correct | |
date_default_timezone_set('Europe/London'); | |
// Backup all files in public_html apart from the gz | |
$siteroot = "/path/to/backup"; | |
$dropbox_email='dropbox@email'; //Dropbox username | |
$dropbox_pass='pass'; // Dropbox password | |
include("DropboxUploader.php"); | |
$uploader = new DropboxUploader($dropbox_email, $dropbox_pass); | |
function FolderToDropbox($dir, $dropbox_link){ | |
$dropbox_folder = 'FolderInDropboxRoot/'; | |
$files = scandir($dir); | |
foreach($files as $item){ | |
if($item != '.' && $item != '..'){ | |
if(is_dir($dir.'/'.$item)) FolderToDropbox($dir.'/'.$item,$dropbox_link); | |
else if(is_file($dir.'/'.$item)) { | |
$clean_dir = str_replace("/path/to/backup", "", $dir); | |
$dropbox_link->upload($dir.'/'.$item,$dropbox_folder.$clean_dir.'/'); | |
} | |
} | |
} | |
} | |
FolderToDropbox($siteroot,$uploader); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment