Created
February 2, 2016 07:16
-
-
Save jsleetw/6121cf7aed69a316e123 to your computer and use it in GitHub Desktop.
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 | |
# power by https://github.com/YouHack/ | |
# Install the script | |
# crontab -e | |
# 1 1 * * * /home/user/shell_script/backup.sh >/dev/null 2>&1 | |
#set up account | |
THESITE='www.backuphero' | |
THEDB='superBigDB' | |
THEDBUSER='DB_big_User' | |
THEDBPW='123456' | |
THEDATE=`date +%d%m%y%H%M` | |
#dump mysql file and gzip it! | |
mysqldump --u $THEDBUSER -p${THEDBPW} $THEDB | gzip > /home/user/backup/dbbackup_${THEDB}_${THEDATE}.bak.gz | |
#tar all web files | |
tar czf /home/user/backup/sitebackup_${THESITE}_${THEDATE}.tgz /home/user/web_folder | |
#keep file in 5 days | |
find /home/user/backup/site* -mtime +5 -exec rm {} \; | |
find /home/user/backup/db* -mtime +5 -exec rm {} \; | |
#rsync file to remote server -- keep delete save folder space | |
rsync -ae ssh --delete /home/user/backup/ remote_user@remote_server.com:/home/user/backup/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment