Last active
January 19, 2017 09:58
-
-
Save wathmal/7a958daf90975a80425fd9f30d468096 to your computer and use it in GitHub Desktop.
bash script to backup wordpress site and database to dropbox
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
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ofdropbox_uploader
to/home/pi/bin/
.https://github.com/andreafabrizi/Dropbox-Uploader
enjoy. ❤️