Created
December 7, 2011 04:32
-
-
Save bbejeck/1441472 to your computer and use it in GitHub Desktop.
Source for Simple WordPress backups Blog
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/sh | |
BLOG=blog_backup | |
BASE_DIR=/home/<username>/webapps/wp | |
USER=remote_username | |
PASS=database_password | |
DBUSER=database_user | |
DATABASE=database_name | |
DEST_DIR=destination_dir | |
IP_ADDRESS=blog_ip_address |
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/sh | |
. backup_config.sh | |
NOW=$(date +"%m%d%Y") | |
FILENAME="${BLOG}_${NOW}.tar.gz" | |
DATABASE_BAK="Database_${BLOG}_${NOW}.gz" | |
echo "Running remote tar backup of blog directory" | |
ssh $USER@$IP_ADDRESS "cd $BASE_DIR && tar -zcf ~/$FILENAME ." | |
echo "Begin remote copy"; scp $USER@$IP_ADDRESS:~/$FILENAME $DEST_DIR \ | |
&& echo "Remote copy successful, removing backup on server"; ssh $USER@$IP_ADDRESS "rm ~/$FILENAME" | |
echo "Starting Mysql dump" | |
ssh $USER@$IP_ADDRESS "mysqldump -u$DBUSER -p$PASS $DATABASE | gzip -c" > $DEST_DIR/$DATABASE_BAK | |
echo "Mysql dump completed" | |
echo "Created backup files:" | |
ls -la $DEST_DIR | grep $NOW |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment