LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 12-18-2007, 10:45 AM   #1
Schiz0
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 10:47 AM.
 
Old 12-18-2007, 10:58 AM   #2
Berhanie
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, 09:31 PM   #3
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,197

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 http://www.linuxquestions.org/bookmarks/tags/backup .
 
  


Reply

Tags
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 06:47 AM
Automatic backup program/script for selected directories JonathonReinhart Linux - Software 14 03-10-2006 10:33 PM
Automatic backup of specified directories? Spreegem Debian 3 07-29-2005 12:08 AM
Automatic Backup? Mirra? naloxone Linux - Software 0 04-28-2004 05:27 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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