Matthew Edlefsen on 17 Dec 2009 09:59:17 -0800


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

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


find voicemail/*/*/INBOX -type f -mtime +180 -print | tar -cT - | ssh ...

should work

-T FILE tells tar to read a list of files to tar from FILE.

-Matt Edlefsen

On Thu, Dec 17, 2009 at 12:18 PM, Kevin McAllister <kevin@mcallister.ws> wrote:
> 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?
>
> Thanks,
> Kevin
>
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug
>
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug