Re: [expert] Script help needed
On Monday 02 Jun 2003 7:29 am, Ray Warren wrote: > On Sun, Jun 01, 2003 at 08:29:26PM +0100, Anne Wilson wrote: > > I want to set up an additional task in the daily cron. The > > script I wrote is > > > > mv -fu /Data/Backup/GnomeCard.vcf /Data/Backup/GnomeCard.vcf.bak > > after this step /Data/Backup/GnomeCard.vcf no longer exists if it > has been modified more recently than .bak > > > cp -fpu /home/anne/GnomeCard.vcf /Data/Backup/GnomeCard.vcf > > If step one was true then the copy will be made as the target file > does not exist > > > By my understanding the -u flag says 'only if it is a later > > version'. > > for later version substitute more recent modification date. > > It looks like the flow for this script is: > working file = /home/anne/ > backup = /Data/Backup > archive = .bak > > 1: change working file > 2A: script runs: backup and archive have the same modification date > no change > 2B: working file is modified more recently than backup so copy > working file to backup 3A: next time script runs: backup has been > modified more recently than archive so move backup to archive > 3B: since backup no longer exists the working file is again more > recent so copy working file to backup even if working file has not > changed. > > So once all of the files exist, the script has to run twice for > each change before copies are no longer made. > > Ray Warren Thanks for replying, Ray. Actually, someone asked me a question off-list. Since I had to spell out the logic for him, it dawned on my what was happening. I left the script alone to see what would happen, and it ran overnight as intended. I have a backup of last evening's changes, with an archive copy of earlier in the day, when the script first was run. It has been suggested that rsync would be more efficient, so I will probably make changes, but I'm happy now that I can achieve the intended. I feel much safer. Anne Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Script help needed
On Sun, Jun 01, 2003 at 08:29:26PM +0100, Anne Wilson wrote: > I want to set up an additional task in the daily cron. The script I > wrote is > > mv -fu /Data/Backup/GnomeCard.vcf /Data/Backup/GnomeCard.vcf.bak after this step /Data/Backup/GnomeCard.vcf no longer exists if it has been modified more recently than .bak > cp -fpu /home/anne/GnomeCard.vcf /Data/Backup/GnomeCard.vcf If step one was true then the copy will be made as the target file does not exist > > By my understanding the -u flag says 'only if it is a later version'. for later version substitute more recent modification date. It looks like the flow for this script is: working file = /home/anne/ backup = /Data/Backup archive = .bak 1: change working file 2A: script runs: backup and archive have the same modification date no change 2B: working file is modified more recently than backup so copy working file to backup 3A: next time script runs: backup has been modified more recently than archive so move backup to archive 3B: since backup no longer exists the working file is again more recent so copy working file to backup even if working file has not changed. So once all of the files exist, the script has to run twice for each change before copies are no longer made. Ray Warren Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com
Re: [expert] Script help needed
So if I completely understand it, there is no .bak file in the beginning ? mv and cp don't see this file, so they assume the sourcefile is newer than the not-existing destination file. Steven On Sun, 2003-06-01 at 21:56, Anne Wilson wrote: On Sunday 01 Jun 2003 8:44 pm, you wrote: > (I'm mailing directly to you because I'm afraid I'm asking a stupid > question now :-) ) > > how do you know it's copied or moved if they are both identical ? > I made one copy of each file to the backup file. After I had run the script I had a *.bak file for each and a corrrectly named one. There is, of course, no way I can prove that the correctly named one is new. Anne