Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-18-2007, 09:45 AM   #1
LQ Newbie
Registered: Dec 2005
Location: Pennsylvania, USA
Distribution: FreeBSD, Ubuntu, and Debian
Posts: 10

Rep: Reputation: 0
Question 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.

Last edited by Schiz0; 12-18-2007 at 09:47 AM.
Old 12-18-2007, 09:58 AM   #2
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
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.
Old 12-18-2007, 08:31 PM   #3
Senior Member
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,194

Rep: Reputation: 105Reputation: 105
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 .


automated, backup, scripting

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic backup to email critical Linux - Software 1 10-04-2006 05:47 AM
Automatic backup program/script for selected directories JonathonReinhart Linux - Software 14 03-10-2006 09:33 PM
Automatic backup of specified directories? Spreegem Debian 3 07-28-2005 11:08 PM
Automatic Backup? Mirra? naloxone Linux - Software 0 04-28-2004 04:27 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration