System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Copy only changed or new files

 
SOLVED
Go to solution
Darren Etheridge_2
Super Advisor

Copy only changed or new files

How can I copy nightly only the files that have been newly created or changed to a NFS mount point (another server) without using Data Protector (I want to keep them in original raw file format)?
3 REPLIES
James R. Ferguson
Acclaimed Contributor

Re: Copy only changed or new files

Hi Darren:

To create the list of files to be copied you could do something like this:

# cat ./listchanged
#!/usr/bin/sh
typeset MYNAME=$(basename $0)
typeset MY_REF=/var/tmp/${MYNAME}.ref
[ -f "${MY_REF}" || touch ${MY_REF}
find / -local -type f -newer ${MY_REF}
touch ${MY_REF}
exit 0

...Every time this is run, the time of execution is recorded as the 'MY_REF' file's mtime. Thus, on subsequent runs, only *local* (non-NFS) files are listed for copying if they have been created or modified since the last execution. The first time the script runs, if the file represented by 'MY_REF' isn't available, nothing will be copied but the threshold will be set for the next run. Thus, it is possible to define the timestamp from which you wnat to begin by simply doing:

# touch YYYYMMDDHHMM.SS ${MY_REF}

Regards!

...JRF...
Steven Schweda
Honored Contributor
Solution

Re: Copy only changed or new files

Have you considered "rsync"? (And "cron"?)
I haven't used it much, but it sounds as if
it might be approximately ideal (if not
actually better than you need).
Chandrahasa s
Valued Contributor

Re: Copy only changed or new files

Hi,

You can download rsync and use.


Chandra