Skip to content

Instantly share code, notes, and snippets.



Last active Jan 19, 2017
What would you like to do?
bash script to backup wordpress site and database to dropbox
#!/usr/bin/env bash
TS=$(date +"%Y-%m-%d");
# zip the whole blog directory
echo "compressing $BLOG_DIR directory"
zip -q -r "$OUT_DIR$PREFIX$" "$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$" /
# delete backups
echo "deleting backups"
echo "all done!"
echo "$TS"

This comment has been minimized.

Copy link
Owner Author

@wathmal 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.


wp-cli need to be installed.

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/.

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