[wellylug] bash scripting help
Mark Signal
mark at databackup.co.nz
Wed Aug 4 12:18:07 NZST 2004
Hi
I have started playing with rsync's -b and -backup-dir options which creates
backups of files prior to changing or deleting them.
by using the date +%A I can have backup/Monday backup/Tuesday
backup/Wednesday etc (I only want to keep 7 days data)
to avoid these directories being deleted by the next rsync (--delete is
used) I use the rsync --exclude=backup/ option
this means that the data stored in the backup directories is cumulative
which I don't want. I can run a "rm -rf backup/`date +%A` at the beginning
of each rsync which is fine if the backup is only run once every day. BUT if
rsync is run multiple times on the same day it will delete the prior backup
of today's changed/deleted data....
if you are still with me... what I need to do is ensure that the rm -rf
portion of the rsync script only runs on the first time that the scrip is
run each day.
Maybe I could create a unique token file at the end of the first days rsync
and check for it each time rsync is run..
something like ... (on Monday for examples sake)
at the end of each rsync: touch (or mkdir -P?) backup\Monday\token\`date
+%j` (day of year)
at the beginning of each rsync: compare date +%j with
/backup/Monday/token/* and if they are the different then
rm -rf backup/Monday/
I am unsure if this is the best way to do this and how exactly to script the
if-compare-then part of it.
any thoughts/suggestions appreciated
cheers
Mark
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.733 / Virus Database: 487 - Release Date: 2/08/2004
More information about the wellylug
mailing list