Adam wrote:
Anyway, now that I have the extra hard disk space, I'm working on a
simple cron task to back up selected directories, since nothing
available seemed to be quite what I wanted. It was straightforward,
except for two lines that I can't seem to get right although I've
tried lots of things. Script excerpts are below. Can anybody point
me in the right direction, please? Thanks!
I figured it out, or rather I figured out one way to do it.
# set flag /not/ to do monthly backup if /mnt/backup/monthly contains
any file that starts with current year and month
# i.e. if today there's any file called ${BACKUP_DIR}/monthly/0902*
### I can't get the next line to detect it reliably somehow
if [ -f "${BACKUP_DIR}/monthly/$(date +%y%m)*" ] ; then
MONTHLY=0
fi
find ${BACKUP_DIR}/monthly/$(date +%y%m)* -quit
$? will be 0 if there are any matches, 1 if no matches
# set flag /not/ to do weekly backup if /mnt/backup/weekly contains
any file with mod time less than about 5 days ago
### next line does not work, always zeros WEEKLY even if no matching
files
find "${BACKUP_DIR}/weekly/*" -mtime -5 -exec test $((WEEKLY=0)) \; -quit
# I understand putting -mtime before -type saves a few microseconds for
stat() calls
find ${BACKUP_DIR}/weekly -mtime -5 -type f -quit
$? will be 0 if there are any matches, 1 if no matches
Adam
_______________________________________________
Mid-Hudson Valley Linux Users Group http://mhvlug.org
http://mhvlug.org/cgi-bin/mailman/listinfo/mhvlug
Upcoming Meetings (6pm - 8pm) MHVLS Auditorium
Feb 4 - Ruby on Rails
Mar 4 - TBD
Apr 1 - TBD