1834086 Members
2330 Online
110063 Solutions
New Discussion

Re: cpio modified files

 
SOLVED
Go to solution
Barry Feinberg
Occasional Advisor

cpio modified files

I am using cpio to copy files to a remote server. Is there a way to copy only files that were modified since the last cpio copy? The syntax I am using is.
find /dir -depth | cpio -oc | remsh "cd ; cpio -icduv"
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: cpio modified files

Hi Barry:

Create a reference file with 'touch' and use 'find -newer ...'. For example:

# touch -m -t 05012359 /tmp/myref # May 1, 2359 hours.

# find / -newer /tmp/myref ...

Regards!

...JRF...
Helen French
Honored Contributor

Re: cpio modified files

Not sure about an option directly with cpio. But you can use lot of options with find command:

-newer
-atime
-mtime
-ctime

# man find - for details
Life is a promise, fulfill it!
S.K. Chan
Honored Contributor

Re: cpio modified files

Just to expand on the "-newer" option. First you create a reference file before you do the first cpio.

# cd /tmp
# touch refA
# (find /dir -xdev|cpio -coax) | remsh venus) "cd /dirA;cpio -icdmuxla"
===>The first cpio, syntax that I normally use ("push method").

For the subsequent cpio you would do ..
# (find /dir -xdev -newer /tmp/refA|cpio -coax) | remsh venus) "cd /dirA;cpio -icdmuxla"

hope it helps ..
Sanjay_6
Honored Contributor

Re: cpio modified files

Hi Barry,

Do not use the -u (unconditional copy) option with the cpio command. This will check the last modified time for the file and will not overwrite the file if the file that exist is of a newer date than the one that was backed up.

Hope this helps.

regds
Barry Feinberg
Occasional Advisor

Re: cpio modified files

Thanks everybody, I used the find with the newer option to get my script to work.