rdeschene2
05-30-2005, 08:54 PM
I have a little bash shell script which is used to backup files (via cron) to an NASLite server every 7 days.
a=$(date +%b_%d_%Y)
tar -lcpf /tmp/laptopbackup.$a.tar /home
ncftpput 192.168.0.5 /Disk-1/laptop /tmp/laptopbackup.$a.tar
The filename thus includes the date on which it is made, which is very handy for the novice. e.g. laptopbackup.May_29_2005.tar
I would like to keep on the NAS only the last 4 weeks of tar archives.
As the filenames include the date, I could do this by having the script delete (via ncftp) all files that were made 5 weeks ago. So if the shell script was running on May 29/2005, this would delete the file named:
laptopbackup.Apr_24_2005
How can I set a variable so that it's value is the date (5 weeks * 7 days/week = ) 35 days ago ? That would do the trick as I could then use
ncftp -rm laptopbackup.($variable for date 35 days ago).tar
to delete these older files ?
Thank you,
Rick D.
a=$(date +%b_%d_%Y)
tar -lcpf /tmp/laptopbackup.$a.tar /home
ncftpput 192.168.0.5 /Disk-1/laptop /tmp/laptopbackup.$a.tar
The filename thus includes the date on which it is made, which is very handy for the novice. e.g. laptopbackup.May_29_2005.tar
I would like to keep on the NAS only the last 4 weeks of tar archives.
As the filenames include the date, I could do this by having the script delete (via ncftp) all files that were made 5 weeks ago. So if the shell script was running on May 29/2005, this would delete the file named:
laptopbackup.Apr_24_2005
How can I set a variable so that it's value is the date (5 weeks * 7 days/week = ) 35 days ago ? That would do the trick as I could then use
ncftp -rm laptopbackup.($variable for date 35 days ago).tar
to delete these older files ?
Thank you,
Rick D.