Reputation: 32388
I'm trying to synchronize two contents of folders with different name:
rsync -av ~/foo [email protected]:/var/www/bar
I'd like to copy the content of foo
into bar
at remote host, but not the directory foo
itself. I've tried something like foo/*
, but rsync doesn't support that.
rsync always creates
/var/www/bar/foo
Upvotes: 218
Views: 100207
Reputation: 1535
It's simple,
rsync /var/www/ /home/var
- copies the contents of /var/www/ but not the www folder itself.
rsync /var/www /home/var
- copies the folder www along with all its contents.
Upvotes: 103
Reputation: 6019
rsync interprets a directory with no trailing slash as copy this directory
, and a directory with a trailing slash as copy the contents of this directory
.
Try rsync -av ~/foo/ [email protected]:/var/www/bar/
Upvotes: 331
Reputation: 31
Navigate into the directory you would like to copy over, so:
cd ~/foo
Run this:
rsync -avz . [email protected]:/var/www/bar
Upvotes: 3
Reputation: 2162
Not related only to rsync, but when you are looking for examples on how to use a GNU/Linux command, you can use "eg" which displays explicit examples. eg is available here, with instructions on how to install it: https://github.com/srsudar/eg
The result for eg rsync
is as follow
# rsync
copy the folder source_dir and its content into destination_dir
rsync -av source_dir destination_dir
copy the contents of source_dir (trailing slash) into destination_dir
rsync -av source_dir/ destination_dir
Upvotes: 36