Created
June 19, 2012 14:56
-
-
Save tomhodgins/2954650 to your computer and use it in GitHub Desktop.
Site and SQL backup for MediaTemple servers
This file contains hidden or 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 | |
##################################################################### | |
## ## | |
## Welcome to the server backup script, before backing up your ## | |
## files be sure to update your SQL username and password below ## | |
## ## | |
## This script assumes you have folders 'server' and 'databases' ## | |
## already created inside your /root/backup/ folder ## | |
## ## | |
##################################################################### | |
### This is the site folder backup | |
cd /var/www/vhosts/ | |
ls > /root/backup/server/filenames.txt | |
cat /root/backup/server/filenames.txt | xargs -IR tar -czvf '/root/backup/server/R.tar.gz' 'R' | |
rm /root/backup/server/filenames.txt | |
echo all websites backed up to /root/backup/server/ | |
### This is the SQL database backup | |
for T in `mysql -N -B -e 'show databases' -u admin -p password`; | |
do echo $T; | |
mysqldump -u admin -p password $T | gzip -c > /root/backup/databases/$T.sql.gz; | |
done | |
echo all databases backed up to /root/backup/databases/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment