smart copy/update routine

Root Boy Jim rbj at uunet.UU.NET
Fri Feb 1 07:18:23 AEST 1991


In article <51818 at sequent.UUCP> edw at sequent.UUCP (Ed Wright) writes:
>In article <1991Jan28.155450.24449 at cec1.wustl.edu> beard at informatics.wustl.edu writes:
>%Is there such a thing available as unix source?  What I need is a
>%program that can be told to copy files from source to target iff the
>%file to be copied does not exist on the target or the source version
>%is newer than the version in the target directory. 

If Sequent would get hip to 4.3, than Ed would be recommending rdist.
It maintains exact copies with identical contents/owner/group/mode/dates.
If you don't have it, it's in our archives. You need sockets to run it.

>make a timestamp file
>run find on your your filesystem looking for files newer than timestamp
>let the result of the find be an argument to tar as filename
>and tar cBf - $filename | (cd /newplace;tar xpBf -)
>When you're done touch timestamp
>Then you're ready for next time.

I assume you mean something like

	(cd $from; tar cBf - `find . -newer stamp -print` ) | \
	(cd $to;  tar xpBf - )
	touch stamp

We'll gloss over 'args too long' or whether to use cpio for now.

You left a window, by doing the obvious thing. You will miss files
modified between the find and the touch. You need two timestamp
file. This leaves a window too, copying some files twice.

	touch newstamp
	find $where -newer stamp -print > list
	mv newstamp stamp
	use cpio/tar/whatever to backup files named in list

Of course, the files we copy could be being modified in either case.

>Ed
>-- 
> I think I've got the hang of it now .... :w  :q  :wq  :wq! ^d  X exit
> X Q  :quitbye  CtrlAltDel   ~~q  :~q  logout  save/quit :!QUIT ^[zz
> ^[ZZ ZZZZ  ^H  ^@  ^L  ^[c  ^# ^E ^X ^I ^T  ?  help  helpquit ^D  ^d
> ^C ^c helpexit ?Quit ?q  ^Kx  /QY  sync;halt   KA9AHQ   edw at sequent.com

You forgot Control Meta Cokebottle :-)
-- 

	Root Boy Jim Cottrell <rbj at uunet.uu.net>
	Close the gap of the dark year in between



More information about the Comp.unix.misc mailing list