tags:

views:

567

answers:

4

Using the Linux command line, I use the scp command to copy up all the files and folders from a certain directory. However, I don't like to consume wasted bandwidth for copying up things I rarely change like my tiny_mce folder. What's the trick to copy up everything but skip a short list of folders?

A: 

A great tool you may want to try out is "lftp".

lftp sftp://etc.etc/ 
lftp> ls 
    --- remote listing ---
lftp> mirror -R -n local/ remote/

You can also use RSync over ssh

rsync -avzp -e ssh /this/dir/  remoteuser@remotehost:/remote/dir/

Should work.

Kent Fredric
+7  A: 

You could try rsync which only copies files that have changed, also works over ssh.

Stuart Grimshaw
+7  A: 

rsync works fine, and in most cases, uses SSH automatically as it's transport protocol. It will compare files and only upload those that have changed - but you can also use an exclude list to specify files in the tree that shouldn't be rsynced anyhow.

Rizwan Kassim
rsync does _not_ use SSH automatically - you have to supply the "-e ssh" flags to do that.
Alnitak
Yes, it does.Rsync 2.6.0 released - The default remote shell is now "ssh" unless you tell configure you want to make something else the default.http://www.samba.org/rsync/
Rizwan Kassim
+2  A: 

Rsync is a good solution, but if you're looking for an alternative:

Let's say, we have a directory "test" contain the directories "foo, bar, baz". In these dirs are a bunch of different file types:

test
|____bar
| |____1.jpg
| |____1.png
| |____1.txt
| |____2.jpg
| |____2.png
| |____2.txt
|____baz
| |____1.avi
| |____2.avi
| |____3.png
|____foo
| |____test.blah
|____test.txt

We want to copy everything except the PNGs

scp $(find /location/of/test -type f ! -name "*.png") # -> Note the logical NOT!!

In this example, the command will put all of the files into the same destination directory - this may not be the behavior you want.