[comp.unix.wizards] Using cp to copy only new files

lthompso@hpcc01.HP.COM (Larry L. Thompson) (06/06/91)

>I would like to run a simple shell program to archive data files from
>my hard disk to an optical disk.  I would like for the archived files
>to be directly usable from the archive (i.e. tar is no good).  Hence,
>what I would like is some way to use the cp command with a qualifier
>that says don't re-copy files that already exist - only new ones.
>
>Either that, or a 'since date' option.  Or something similar.  Any
>suggestions??  Thanks!
>
>Bryan Emery
>Computer Systems Analyst
>Lockheed Engineering and Sciences Corp
>White Sands Test Facility
>----------
>
OK this is a two step process. You first need to touch a file somewhere
that will be used as the reference data for filtering files that are newer
than itself. 

Now just use this file along with the find command piped into cpio. Like
this:

find . -newer <filename> -hidden -print | cpio -pudmvx <destination>


Larry
------------------------------------------------------------------------------
Larry L. Thompson                       Hewlett-Packard Co.  
Unix:   lthompso@hpcmfs.corp.hp.com     3500 Deer Creek Rd 26U-13
HPDesk: larry_l_thompson@hp0000         Palo Alto, CA.  94304
Tel: (415) 857-4437                     Un-employed

les@chinet.chi.il.us (Leslie Mikesell) (06/06/91)

In article <2620002@hpcc01.HP.COM> lthompso@hpcc01.HP.COM (Larry L. Thompson) writes:
>>I would like to run a simple shell program to archive data files from
>>my hard disk to an optical disk.  I would like for the archived files
>>to be directly usable from the archive (i.e. tar is no good).  Hence,
>>what I would like is some way to use the cp command with a qualifier
>>that says don't re-copy files that already exist - only new ones.

>OK this is a two step process. You first need to touch a file somewhere
>that will be used as the reference data for filtering files that are newer
>than itself. 
>find . -newer <filename> -hidden -print | cpio -pudmvx <destination>

Actually, cpio will already do exactly what is desired if you leave
out the -u option.

find . -print |cpio -pudmv dest_dir
 will copy all files except those that are newer or the same age on
the destination directory or where there are restrictive permissions.

Les Mikesell
  les@chinet.chi.il.us