Daily Weekly and Monthly DB backup with logrotate?

Solution 1:

Check out the script AutoMySQLBackup https://sourceforge.net/projects/automysqlbackup/

This is a great script to backup one/all databases, using mysqldump (assuming these are mysql databases)

Solution 2:

You can add nodateext option to your database logrotate conf.

You can also put some script in postrotate section, which copy/move your daily and weekly monthly backup to new location, which will prevent from deleting it by logrotate.

Another solution is to write simple shell script to do and rotate backups and put it to cron. Some usefull commands to use in the script

date +%u - day of week
date +%d - day of month
find /path -type f -daystart -ctime +30 -exec rm -f '{}' \; - remove files older than 30 days

Why you want to have this kind of backups? For me this stategy has no sense. Mysqldump create only full database backup, so you don't weekly/monthly backups.

Daily, weekly and monthly backups are necessary, when you use full/differential/incremental backups. You need only few last backups in case of database corruption.