Created
October 21, 2012 00:42
-
-
Save yasyf/3925345 to your computer and use it in GitHub Desktop.
Simple, Complete Incremental WordPress Backup
This file contains 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 | |
header("Cache-Control: no-cache, must-revalidate"); | |
header('HTTP/1.1 200 OK'); | |
function wpcomplete_searchBackups($dir) { | |
global $searchnames; | |
if ($handle = opendir($dir)) { | |
while (false !== ($file = readdir($handle))) { | |
if ($file != "." && $file != ".." && $file != "index.php" && $file != 'database.sql' && $file != '.wpcmanifest' && is_file($dir.'/'.$file)) { | |
$searchnames[] = $dir.'/'.$file; | |
} | |
else if ($file != "." && $file != ".." && $file != "index.php" && $file != 'database.sql' && $file != '.wpcmanifest' && is_dir($dir.'/'.$file)) { | |
wpcomplete_searchBackups($dir.'/'.$file); | |
} | |
} | |
closedir($handle); | |
} | |
if (!is_array($searchnames)) { | |
$searchnames = array(); | |
} | |
} | |
wpcomplete_searchBackups("wp-content/plugins/wp-complete-backup/storage/"); | |
if($_REQUEST['unlink'] == "true") | |
{ | |
unlink($searchnames[0]); | |
//echo("$searchnames[0] deleted!"); | |
} | |
else { | |
header("Location: http://blog.you.com/$searchnames[0]"); | |
} | |
?> |
This file contains 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
#!/bin/bash | |
if [ -z "$1" ] | |
then | |
echo "commit message not defined" | |
else | |
curl "http://blog.you.com/wp-complete-backup/{api-key-here}/type-both" | |
sleep 10 | |
cd /tmp | |
wget "http://blog.you.com/back.php" | |
name=$(ls | grep mycodetreebu-*.zip | tail | xargs basename -s .zip) | |
unzip -qq $name".zip" -d $name | |
curl "http://blog.you.com/back.php?unlink=true" | |
rm -rf /tmp/$name/wp-content/cache/ | |
rsync -r $name/ /Some/Location/Where/Backups/Are/Stored/ | |
cd /Some/Location/Where/Backups/Are/Stored/ | |
git add . | |
git commit -a -m "$1" | |
git push -u origin master | |
echo "Commited and Pushed Blog: $1" | |
unset MSG | |
rm -rf /tmp/$name | |
rm -f /tmp/$name".zip" | |
fi |
Sadly the blog post isn't working anymore. Can you share the text on some other platform?
Blogpost archive: https://web.archive.org/web/20131106055356/http://www.yasyf.com//coding/simple-incremental-wordpress-backups-with-php-and-bash/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sadly the blog post isn't working anymore. Can you share the text on some other platform?