Kevin McAllister on 17 Dec 2009 09:18:23 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] find, xargs, tar and ssh or selectively backing up some files on another server

I was hoping to selectively delete files based on age, and wanted to back them up first, including their directory structure.  Normally I could use:

find voicemail/*/*/INBOX -type f -mtime +180 -print0 | xargs -0 tar -zrvf /var/tmp/voicemails-180.tar.gz

And then all the additional calls to tar by xargs (when it fills up a command line) would just update the existing file instead of overwriting it, however, the reason I want to do this is because my disk is approaching full and so I want to back up the old files to another server and then delete them from this one.  But the -r option is incompatible with writing to STDOUT.  

So something like:
find voicemail/*/*/INBOX -type f -mtime +180 -print0 | xargs -0 tar -zrv | ssh user@server 'cat - > foo.tar.gz'

doesn't work, and if I create a new file using tar -c I just keep overwriting the last one on the server.

I punted and just backed it all up, because I have plenty of storage available using this:
tar c voicemail | ssh user@server 'cat -> foo.tar'

So what is the obvious way to accomplish my goal that I've overlooked?


Philadelphia Linux Users Group         --
Announcements -
General Discussion  --