How do I copy all files and directories, except certain ones over ssh?
Clash Royale CLAN TAG#URR8PPP
up vote
22
down vote
favorite
Using the Linux command line, I use the scp
command, to copy all the files and folders from a certain directory. However, I don't like to consume bandwidth, for copying things I rarely change like my tiny_mce
folder. What's the trick to copy everything, but skip a short list of folders?
ssh synchronization file-copy remote
migrated from stackoverflow.com Jun 2 '11 at 0:55
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
22
down vote
favorite
Using the Linux command line, I use the scp
command, to copy all the files and folders from a certain directory. However, I don't like to consume bandwidth, for copying things I rarely change like my tiny_mce
folder. What's the trick to copy everything, but skip a short list of folders?
ssh synchronization file-copy remote
migrated from stackoverflow.com Jun 2 '11 at 0:55
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
22
down vote
favorite
up vote
22
down vote
favorite
Using the Linux command line, I use the scp
command, to copy all the files and folders from a certain directory. However, I don't like to consume bandwidth, for copying things I rarely change like my tiny_mce
folder. What's the trick to copy everything, but skip a short list of folders?
ssh synchronization file-copy remote
Using the Linux command line, I use the scp
command, to copy all the files and folders from a certain directory. However, I don't like to consume bandwidth, for copying things I rarely change like my tiny_mce
folder. What's the trick to copy everything, but skip a short list of folders?
ssh synchronization file-copy remote
ssh synchronization file-copy remote
edited Nov 26 at 8:08
Michael Prokopec
71316
71316
asked Nov 15 '08 at 23:43
Mike McKee
migrated from stackoverflow.com Jun 2 '11 at 0:55
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Jun 2 '11 at 0:55
This question came from our site for professional and enthusiast programmers.
add a comment |
add a comment |
9 Answers
9
active
oldest
votes
up vote
19
down vote
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.
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
add a comment |
up vote
12
down vote
You could try rsync which only copies files that have changed, also works over ssh.
add a comment |
up vote
9
down vote
Using rsync --exclude
is the more obvious choice here, but if you really want to just send a few files or folders and have something specific to exclude, you can use shell globing with scp
. First make sure you have the right globing options set in your shell. For bash run shopt -s extglob
and for zsh use setopt ksh_glob
. Then something like this:
scp /path/to/folder/!(tiny_mce|other_folder|*.bak) user@host:target_path
...would copy everything in the source folder except for things matching the given pattern. Obviously you can get creative with that part.
add a comment |
up vote
7
down vote
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.
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or[*?
).
– Gilles
Jun 10 '11 at 21:44
add a comment |
up vote
3
down vote
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.
add a comment |
up vote
0
down vote
I just finished writing how I prefer unison to rsync any day, since it
- doesn't need a daemon, other than ssh for transport
- lets me modify files on either side any time--multiple masters easily, while I only need to push a sync request from one side
- I am a stickler when it comes to modtimes, attributes/permissions, softlinks etc. No problems with that; for one project I even use 4 mirrors, one being a cygwin host. See my example crontab setup.
- supports exclusions like
*.bak
. Samples in my config file
add a comment |
up vote
0
down vote
Using Secure Copy - scp
scp -r file user@host:
To copy many file
scp /directory/* user@host:destinationPath
To copy some files
scp /directory/!(*.doc) user@host:destinationPath
It copies content of directory except .doc files
add a comment |
up vote
0
down vote
I would certainly recommend you rsync.
rsync -vra --exclude="what you want to exclude" -e ssh folder user@remotehost:/folder
add a comment |
up vote
0
down vote
This is what worked for me when I ran it from destination server.
rsync -av --progress user@servername:/sourcefolder /destinationfolder --exclude thefoldertoexclude
add a comment |
9 Answers
9
active
oldest
votes
9 Answers
9
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
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.
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
add a comment |
up vote
19
down vote
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.
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
add a comment |
up vote
19
down vote
up vote
19
down vote
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.
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.
edited Apr 28 '13 at 14:35
Anthon
59.9k17102163
59.9k17102163
answered Nov 16 '08 at 1:04
Rizwan Kassim
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
add a comment |
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
rsync does not use SSH automatically - you have to supply the "-e ssh" flags to do that.
– Alnitak
Nov 16 '08 at 19:44
4
4
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
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. samba.org/rsync
– Rizwan Kassim
Nov 16 '08 at 20:18
add a comment |
up vote
12
down vote
You could try rsync which only copies files that have changed, also works over ssh.
add a comment |
up vote
12
down vote
You could try rsync which only copies files that have changed, also works over ssh.
add a comment |
up vote
12
down vote
up vote
12
down vote
You could try rsync which only copies files that have changed, also works over ssh.
You could try rsync which only copies files that have changed, also works over ssh.
answered Nov 15 '08 at 23:49
Stuart Grimshaw
add a comment |
add a comment |
up vote
9
down vote
Using rsync --exclude
is the more obvious choice here, but if you really want to just send a few files or folders and have something specific to exclude, you can use shell globing with scp
. First make sure you have the right globing options set in your shell. For bash run shopt -s extglob
and for zsh use setopt ksh_glob
. Then something like this:
scp /path/to/folder/!(tiny_mce|other_folder|*.bak) user@host:target_path
...would copy everything in the source folder except for things matching the given pattern. Obviously you can get creative with that part.
add a comment |
up vote
9
down vote
Using rsync --exclude
is the more obvious choice here, but if you really want to just send a few files or folders and have something specific to exclude, you can use shell globing with scp
. First make sure you have the right globing options set in your shell. For bash run shopt -s extglob
and for zsh use setopt ksh_glob
. Then something like this:
scp /path/to/folder/!(tiny_mce|other_folder|*.bak) user@host:target_path
...would copy everything in the source folder except for things matching the given pattern. Obviously you can get creative with that part.
add a comment |
up vote
9
down vote
up vote
9
down vote
Using rsync --exclude
is the more obvious choice here, but if you really want to just send a few files or folders and have something specific to exclude, you can use shell globing with scp
. First make sure you have the right globing options set in your shell. For bash run shopt -s extglob
and for zsh use setopt ksh_glob
. Then something like this:
scp /path/to/folder/!(tiny_mce|other_folder|*.bak) user@host:target_path
...would copy everything in the source folder except for things matching the given pattern. Obviously you can get creative with that part.
Using rsync --exclude
is the more obvious choice here, but if you really want to just send a few files or folders and have something specific to exclude, you can use shell globing with scp
. First make sure you have the right globing options set in your shell. For bash run shopt -s extglob
and for zsh use setopt ksh_glob
. Then something like this:
scp /path/to/folder/!(tiny_mce|other_folder|*.bak) user@host:target_path
...would copy everything in the source folder except for things matching the given pattern. Obviously you can get creative with that part.
edited Oct 23 '13 at 1:12
slm♦
245k66505671
245k66505671
answered Jun 10 '11 at 8:51
Caleb
50k9146190
50k9146190
add a comment |
add a comment |
up vote
7
down vote
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.
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or[*?
).
– Gilles
Jun 10 '11 at 21:44
add a comment |
up vote
7
down vote
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.
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or[*?
).
– Gilles
Jun 10 '11 at 21:44
add a comment |
up vote
7
down vote
up vote
7
down vote
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.
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.
edited Apr 28 '13 at 14:36
Anthon
59.9k17102163
59.9k17102163
answered Nov 18 '08 at 16:00
simonm
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or[*?
).
– Gilles
Jun 10 '11 at 21:44
add a comment |
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or[*?
).
– Gilles
Jun 10 '11 at 21:44
1
1
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or
[*?
).– Gilles
Jun 10 '11 at 21:44
Note that this answer only works if the file and directory names involved don't contain any shell special characters (whitespace or
[*?
).– Gilles
Jun 10 '11 at 21:44
add a comment |
up vote
3
down vote
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.
add a comment |
up vote
3
down vote
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.
add a comment |
up vote
3
down vote
up vote
3
down vote
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.
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.
answered Nov 15 '08 at 23:45
Kent Fredric
20319
20319
add a comment |
add a comment |
up vote
0
down vote
I just finished writing how I prefer unison to rsync any day, since it
- doesn't need a daemon, other than ssh for transport
- lets me modify files on either side any time--multiple masters easily, while I only need to push a sync request from one side
- I am a stickler when it comes to modtimes, attributes/permissions, softlinks etc. No problems with that; for one project I even use 4 mirrors, one being a cygwin host. See my example crontab setup.
- supports exclusions like
*.bak
. Samples in my config file
add a comment |
up vote
0
down vote
I just finished writing how I prefer unison to rsync any day, since it
- doesn't need a daemon, other than ssh for transport
- lets me modify files on either side any time--multiple masters easily, while I only need to push a sync request from one side
- I am a stickler when it comes to modtimes, attributes/permissions, softlinks etc. No problems with that; for one project I even use 4 mirrors, one being a cygwin host. See my example crontab setup.
- supports exclusions like
*.bak
. Samples in my config file
add a comment |
up vote
0
down vote
up vote
0
down vote
I just finished writing how I prefer unison to rsync any day, since it
- doesn't need a daemon, other than ssh for transport
- lets me modify files on either side any time--multiple masters easily, while I only need to push a sync request from one side
- I am a stickler when it comes to modtimes, attributes/permissions, softlinks etc. No problems with that; for one project I even use 4 mirrors, one being a cygwin host. See my example crontab setup.
- supports exclusions like
*.bak
. Samples in my config file
I just finished writing how I prefer unison to rsync any day, since it
- doesn't need a daemon, other than ssh for transport
- lets me modify files on either side any time--multiple masters easily, while I only need to push a sync request from one side
- I am a stickler when it comes to modtimes, attributes/permissions, softlinks etc. No problems with that; for one project I even use 4 mirrors, one being a cygwin host. See my example crontab setup.
- supports exclusions like
*.bak
. Samples in my config file
edited Apr 13 '17 at 12:37
Community♦
1
1
answered Feb 2 '12 at 23:01
Marcos
1,12711228
1,12711228
add a comment |
add a comment |
up vote
0
down vote
Using Secure Copy - scp
scp -r file user@host:
To copy many file
scp /directory/* user@host:destinationPath
To copy some files
scp /directory/!(*.doc) user@host:destinationPath
It copies content of directory except .doc files
add a comment |
up vote
0
down vote
Using Secure Copy - scp
scp -r file user@host:
To copy many file
scp /directory/* user@host:destinationPath
To copy some files
scp /directory/!(*.doc) user@host:destinationPath
It copies content of directory except .doc files
add a comment |
up vote
0
down vote
up vote
0
down vote
Using Secure Copy - scp
scp -r file user@host:
To copy many file
scp /directory/* user@host:destinationPath
To copy some files
scp /directory/!(*.doc) user@host:destinationPath
It copies content of directory except .doc files
Using Secure Copy - scp
scp -r file user@host:
To copy many file
scp /directory/* user@host:destinationPath
To copy some files
scp /directory/!(*.doc) user@host:destinationPath
It copies content of directory except .doc files
answered Dec 8 '15 at 9:34
Yogeesh H T
1212
1212
add a comment |
add a comment |
up vote
0
down vote
I would certainly recommend you rsync.
rsync -vra --exclude="what you want to exclude" -e ssh folder user@remotehost:/folder
add a comment |
up vote
0
down vote
I would certainly recommend you rsync.
rsync -vra --exclude="what you want to exclude" -e ssh folder user@remotehost:/folder
add a comment |
up vote
0
down vote
up vote
0
down vote
I would certainly recommend you rsync.
rsync -vra --exclude="what you want to exclude" -e ssh folder user@remotehost:/folder
I would certainly recommend you rsync.
rsync -vra --exclude="what you want to exclude" -e ssh folder user@remotehost:/folder
answered Dec 8 '15 at 10:44
amit singh
30726
30726
add a comment |
add a comment |
up vote
0
down vote
This is what worked for me when I ran it from destination server.
rsync -av --progress user@servername:/sourcefolder /destinationfolder --exclude thefoldertoexclude
add a comment |
up vote
0
down vote
This is what worked for me when I ran it from destination server.
rsync -av --progress user@servername:/sourcefolder /destinationfolder --exclude thefoldertoexclude
add a comment |
up vote
0
down vote
up vote
0
down vote
This is what worked for me when I ran it from destination server.
rsync -av --progress user@servername:/sourcefolder /destinationfolder --exclude thefoldertoexclude
This is what worked for me when I ran it from destination server.
rsync -av --progress user@servername:/sourcefolder /destinationfolder --exclude thefoldertoexclude
edited Aug 17 '17 at 19:07
chaos
34.8k773115
34.8k773115
answered Aug 17 '17 at 18:42
user2373210
31
31
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f14199%2fhow-do-i-copy-all-files-and-directories-except-certain-ones-over-ssh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown