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

Tar Restore Newer Files Only

Go to solution
Bob Ferro
Regular Advisor

Tar Restore Newer Files Only

I need to tar up some directories on server A and tar restore them to server B. But when I restore, I only want to restore any file that has a newer date from SERVER A. This way I don't overlay any file that was updated on server B. I can't exclude the files from the tar backup because I don't know if it's newer or older than the files on server B. These are directories with tons of files, too difficult to do it manually. Can I use tar or something else?
Steven E. Protter
Exalted Contributor

Re: Tar Restore Newer Files Only


I think I'd use rsync -e ssh

Looking at the man page for rsync it is capable of what you require.

Example run from host a to host b:

rsync -avH --stats --delete -e ssh /var/httpd/ user@hostb/web/

Steven E Protter
Owner of ISN Corporation
James R. Ferguson
Acclaimed Contributor

Re: Tar Restore Newer Files Only

HI Bob:

You can use 'pax' to handle your 'tar' archives. With 'pax' "...If both the -u and -n flags are specified, the pax command does not consider a file selected unless it is newer than the file to which it is compared."


Bob Ferro
Regular Advisor

Re: Tar Restore Newer Files Only

My finals results were that I used tar on the source server, then I used pax to restore on the destination server. Everything worked out fine and very easy to use. Thanks for all your help.
Bob Ferro
Regular Advisor

Re: Tar Restore Newer Files Only

When I want to know or learn anything about HP Unix, I come to this forum, you guys are the best. Nobody can touch you guys.