Removing obsolete backup files and containing directory
Hi, This is my first post in LQ
I'm an Oracle DBA. My database writes backup files to ../Backup area. After writing those file to tape i would like to remove them from disk. That would be simple for me. But I want to keep last five (5) sets of files on disk for faster restore (please All mighty never force me to need and use it). I need a script that would do the chore for me. Directory structure is something like this ../Backup/db1/before_today/20090310 ../Backup/db1/before_today/20090311 ../Backup/db1/before_today/20090312 ../Backup/db2/before_today/20090310 ../Backup/db2/before_today/20090311 ../Backup/db2/before_today/20090312 I want to delete (rm -r) directory ../20090312 for db1 and db2 every day at 7:00 I would appreciate help from linux expert Regards Franjo :) |
It looks like you want
Code:
rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d) Code:
echo rm -r /path/db{1,2}/before_today/$(date --date='3 days ago' +%Y%M%d) Put the above command in your crontab - see man crontab for details. |
Thanks, I just needed what I got.
I applied solution, it works and is small and beautiful. Regards Franjo |
All times are GMT -5. The time now is 03:49 PM. |