$ crontab -e
59 23 * * * /home/john/bin/backup.sh > /home/john/logs/backup.log 2>&1
------------------------------------------------------------------------------
### backup.sh ###
### delete site older than 7 day
find /home/backups/sites/ -name '*_site.tar.gz' -mtime +7 -delete
### delete db older than 7 day
find /home/backups/databases/ -name '*_dbsite.sql.gz' -mtime +7 -delete
### backup site
tar -zcf /home/backups/sites/`date "+%y%m%d"`_site.tar.gz /home/site/
### backup db site
mysqldump -u env -ppassword db_name | gzip -9 > /home/backups/databases/`date "+%y%m%d"`_dbsite.sql.gz
Related
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
* * * * * command to be executed
- http://juuier.blogspot.com/2009/01/command-line.html
- http://juuier.blogspot.com/2012/10/delete-backup-file-older-than-7-day-by.html
- http://juuier.blogspot.com/2012/10/backup-mysqldump-error-crashed-and-last.html
- http://juuier.blogspot.com/2009/03/backup-and-restore-mysql-database-by.html
- http://juuier.blogspot.com/2009/07/backup-and-restore-mssql-database-by.html
- http://juuier.blogspot.com/2009/07/7-zip-command-line.html
- http://juuier.blogspot.com/2009/01/backup-all-ms-sql-server-databases.html
- http://potatokorner.blogspot.com/2009/01/script-to-make-tar-gzip-archives-of.html
No comments:
Post a Comment