Skip to content

Instantly share code, notes, and snippets.

@mgratzer
Created December 7, 2012 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgratzer/4232138 to your computer and use it in GitHub Desktop.
Save mgratzer/4232138 to your computer and use it in GitHub Desktop.
Tiny shell script to backup WordPress on Dropbox. Schedule this script with cron and you'r done.
#!/bin/sh
NAME="blogname"
DIR="/var/www/blogfolder"
SQL="blogdatabase"
U="dbuser"
P="dbpassword"
NOW=$(date +"%m_%d_%Y")
FILE="$NAME.$NOW.tar.gz"
TARGET="/root/Dropbox/Backup/$FILE"
rm -Rf /tmp/wpbackup_$NAME
mkdir /tmp/wpbackup_$NAME
cd /tmp/wpbackup_$NAME
mysqldump --add-drop-table -u$U -p$P $SQL > $SQL.sql
cp $DIR . -Rf
tar -pczf $FILE .
mv $FILE $TARGET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment