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

Justin MacCarthy macarthy at iol.ie
Mon Mar 25 17:15:21 GMT 2002


Opps...There should be $STARTDATE++ in there somewhere ...

Justin 


> Justin MacCarthy
> Sent: Monday, March 25, 2002 5:06 PM
> To: ilug at linux.ie
> Subject: RE: [ILUG] Backup script using bash, find & zip
> 
> 
> 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 -@
> 	DAYSAGO = $FIRSTZIPDATE - $STARTDATE
> done
> echo
> exit 0
> 
> TIA 
> 
> Justin 
> 
> 
> > > I have a very simple bash script that everyday backs up any 
> > files modified
> > > yesterday to a zip file. as follows
> > > 
> > > #!/bin/bash
> > > 
> > > FILENAME=`date --date=yesterday +%d_%m_%Y.ZIP`
> > > find /d/data -daystart -mtime 1 | zip /d/backups/$FILENAME -@
> > > 
> > > 
> > > However there is already is data in the /d/data directory, so 
> I want to
> > > modify the script to create zips for all the file that where 
> > there BEFORE I
> > > started using this script
> > > 
> > > logic is
> > > 
> > > #get earliest mdate in the directory is [startdate]
> > > 
> > > #first zip file date is  (I can hard code this in) [firstzipdate]
> > > 
> > > #Loop from startdate to firstzipdate and create a zip for that date
> > > #(if there are any files ) zipfilename format = dd_mm_yyyy.zip
> > > 
> > > 
> > > 
> > > Can anyone point me in the right direction?
> > 
> > Any numeric arguments to find can have + or -
> > prepended to mean more or less than respectively,
> > so you probably want...
> > 
> > find /d/data -daystart -mtime +1 | zip /d/backups/orig.ZIP
> > 
> > Padraig.
> > 
> > 
> > -- 
> > Irish Linux Users' Group: ilug at linux.ie
> > http://www.linux.ie/mailman/listinfo/ilug for (un)subscription 
> > information.
> > List maintainer: listmaster at linux.ie
> > 
> > 
> > 
> 
> -- 
> Irish Linux Users' Group: ilug at linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription 
> information.
> List maintainer: listmaster at linux.ie
> 
> 
> 




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