[ILUG] Backup script using bash, find & zip
Padraig Brady
padraig at antefacto.com
Mon Mar 25 14:42:40 GMT 2002
Justin MacCarthy wrote:
> 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.
More information about the ILUG
mailing list