LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Automatic Backup Script (http://www.linuxquestions.org/questions/linux-general-1/automatic-backup-script-607624/)

Schiz0 12-18-2007 10:45 AM

Automatic Backup Script
 
I have a script that runs daily, creating backups of my MySQL database (Two different tables), along with my web root. Thus, creating three backup files each night.

I would like to have a script that stores weekly backups. I would need to copy the three most recently modified files out of the daily/ dir, into the weekly/ dir (Three files because I have three backup files each night...).

I'm not sure how to accomplish this. I know "ls -t" sorts by modified time. It would be awesome if "find" had a sort and limit option or something, but unfortunately the man page doesn't mention such a feature. mv `ls -t | head -1` weekly/ would work, but that would only copy the first file, not all three.

Thank you for your time and replies.

Berhanie 12-18-2007 10:58 AM

That's what pipe is for. An alternative to checking access times is to tack the date to the name of the file (e.g. filename-`date +%F`) and sort on the filename suffix.

choogendyk 12-18-2007 09:31 PM

You can script all kinds of stuff yourself. Then, after a while it gets to the point where you just decide to adopt something that's publicly available. I reached that point a while ago. For MySQL, the Zmanda Recovery Manager (ZRM) for MySQL does the trick. Then I have Amanda manage backing up those dumps and the web directories. I do it to tape, but you can do it to disk. See the links at http://www.linuxquestions.org/bookmarks/tags/backup .


All times are GMT -5. The time now is 11:35 AM.