Created
November 2, 2015 13:14
-
-
Save danilchenko/636fef3ecc55eb9e76c3 to your computer and use it in GitHub Desktop.
bash backups script
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/bash | |
| # mysql backup | |
| mysqldump --user={USERNAME} --host=localhost --password={PASSWORD} {DATABASE_NAME} > /backups/{SITE}/{DATABASE_NAME}.sql; | |
| tar -Jcf /backups/{SITE}/DB-`date +%F--%H-%M`.tar.gz /backups/{SITE}/{DATABASE_NAME}.sql; | |
| rm /backups/{SITE}/{DATABASE_NAME}.sql -rf; | |
| # files backup | |
| tar -Jcf /backups/{SITE}/FILES-`date +%F--%H-%M`.tar.gz /var/www/{SITE}/*; | |
| find /backups/{SITE} -type f -mtime +5 -delete; # delete files older than 5 days | |
| # cron task | |
| # 0 1 * * * /root/backup.sh > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment