LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] Backup script using bash, find & zip

[ILUG] Backup script using bash, find & zip

Conor Daly conor.daly at oceanfree.net
Tue Mar 26 18:35:45 GMT 2002


On Mon, Mar 25, 2002 at 05:05:30PM -0000 or so it is rumoured hereabouts, 
Justin MacCarthy thought:
> To change the question slightly;
> 
> > > #get earliest mdate in the directory is [STARTDATE]
> 
> How do I get the earliest mdate on file in a directory????
> 
> otherwise her is what I got so far
> 
> FIRSTZIPDATE = 25032002
> DAYSAGO = $FIRSTZIPDATE - $STARTDATE
> 
> while [ "$STARTDATE" -lt "$FIRSTZIPDATE" ]
> do
> 	
> 	FILENAME=`date --date='$DAYSAGO days ago' +%d_%m_%Y.ZIP`
> 	find /d/data -daystart -mtime -$DAYSAGO | zip /d/backups/$FILENAME -@
                                      ^^^^^^^^^

AFAI understand it, this will put *everything* before $DAYSAGO into the
zip file for each of the days between $STARTDATE and $FIRSTZIPDATE which
*doesn't* appear to be what you want.  Assuming you want a single zip file
per day containing *only* that day's files you should use 

"-mtime $DAYSAGO"

in the line above.

> 	DAYSAGO = $FIRSTZIPDATE - $STARTDATE
> done
> echo
> exit 0

Conor
-- 
Conor Daly <conor.daly at oceanfree.net>

Domestic Sysadmin :-)
---------------------
Faenor.cod.ie
  4:39pm  up 17 days, 21:19,  0 users,  load average: 0.00, 0.00, 0.00
Hobbiton.cod.ie
  4:37pm  up 1 day,  5:55,  2 users,  load average: 0.12, 0.06, 0.02




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell