From: Jim on
I have come up with this problem, searched the archives but did not
find a good solution.

I have a directory called archives. I want to find all the files
ending with ".mbox", and I want to scp all those files to another
server. but the trick is that I need to preserve the directory
structure.

I came up with something like

find archives -name "*.mbox" | xargs scp user(a)server:/somedir, but
this does not preserve the directory structure(does not create parent
directory if necessary)..

Thank you for any pointers!

Jim
From: Jim on
I could do sth like
find . -type f -name "*.mbox" | xargs tar cvf mbox.tar and then scp to
another server and then untar

but is there a way to eliminate the need for mbox.tar(the temporary
tar file)?

Thank you!
Jim
From: Harry on
On Mar 5, 12:35 pm, Jim <student.northwest...(a)gmail.com> wrote:
> I could do sth like
> find . -type f -name "*.mbox" | xargs tar cvf mbox.tar and then scp to
> another server and then untar
>
> but is there a way to eliminate the need for mbox.tar(the temporary
> tar file)?

find . -type f -name "*.mbox" | tar cf - | ssh
user(a)server "cd somedir ; tar xf -"

From: Sven Mascheck on
Harry wrote:

> [...] ssh user(a)server "cd somedir ; tar xf -"

[...] ssh user(a)server "cd somedir && tar xf -"

don't risk the non-accessible directory
From: Jim on
Thank you Harry and Sven, it works too well!

Jim