Reputation: 303
The following command works great for me for a single file:
scp [email protected]:foobar.txt /some/local/directory
What I want to do is do it recursive (i.e. for all subdirectories / subfiles of a given path on server), merge folders and overwrite files that already exist locally, and finally downland only those files on server that are smaller than a certain value (e.g. 10 mb).
How could I do that?
Upvotes: 0
Views: 115
Reputation: 2188
Use rsync.
Your command is likely to look like this:
rsync -az --max-size=10m [email protected]:foobar.txt /some/local/directory
-a
(archive mode - the sync is recursive, transfers ownership, attributes, symlinks among other things)
-z
(compresses transfer)
--max-size
(only copies files up to a certain size)
There are many more flags which may be suitable. Checkout the docs for more details - http://linux.die.net/man/1/rsync
Upvotes: 1
Reputation: 26164
First option: use rsync
.
Second option, and it's not going to be a one liner, but can be done in three or four lines:
Create a tar archive on the remote system using ssh
.
Copy the tar from remote system with scp
.
Untar the archive locally.
If the creation of the archive gets a bit complicated and involves using find
and/or tar
with several options it is quite practical to create a script which would do that locally, upload it on the server with scp
, and only then execute remotely with ssh
.
Upvotes: 0