Skip to content

Instantly share code, notes, and snippets.

@wathmal wathmal/wpbackup.sh
Last active Jan 19, 2017

Embed
What would you like to do?
bash script to backup wordpress site and database to dropbox
#!/usr/bin/env bash
BLOG_DIR="/var/www/html/blog/"
OUT_DIR="/home/pi/temp/"
PREFIX="wp_"
TS=$(date +"%Y-%m-%d");
# zip the whole blog directory
echo "compressing $BLOG_DIR directory"
zip -q -r "$OUT_DIR$PREFIX$TS.zip" "$BLOG_DIR"
# dump the wordpress db
echo "dumping wordpress db"
/usr/local/bin/wp db export "$OUT_DIR$PREFIX$TS.sql" "--path=$BLOG_DIR"
# uploading to dropbox
echo "uploading to dropbox"
/home/pi/bin/dropbox_uploader -p upload "$OUT_DIR$PREFIX$TS.sql" /
/home/pi/bin/dropbox_uploader -p upload "$OUT_DIR$PREFIX$TS.zip" /
# delete backups
echo "deleting backups"
rm $OUT_DIR$PREFIX$TS.sql
rm $OUT_DIR$PREFIX$TS.zip
echo "all done!"
echo "$TS"
@wathmal

This comment has been minimized.

Copy link
Owner Author

wathmal commented Jan 19, 2017

backup wordpress site and database to dropbox

a bash script to backup wordpress website and its database to dropbox. run this script as a cron job to maintain backups at pre-defined time intervals.

dependencies

wp-cli need to be installed.
http://wp-cli.org/

dropbox_uploader need be installed and setup to use your dropbox app. make sure to create a symlink of dropbox_uploader to /home/pi/bin/.
https://github.com/andreafabrizi/Dropbox-Uploader

change the locations for binaries. /home/pi/ to home/username/

enjoy. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.