Hi, I have a simple backup script trigged by cron, below... it creates a backup file each day named for that day-- i.e. "db_01-03-2010.sql.bz2"
This works perfectly.
I want to ADD to this script so it computes the date for 7 days prior, and then removes that file-- so when "db_01-10-2010.sql.bz" is created, it'll figure out the date 7 days before (01-03-2010) and remove that file.
Obviously this is a hair non-trivial and I can't just subtract 7 from the day value, since the date 7 days before 01-03-2010 is 12-27-2009, etc.
How can I do this in a bash shell script?
mysqldump -u mysql_user -pmysql_pass tablename | bzip2 -c > /my/backups/db_`date +%m-%d-%Y`.sql.bz2