Discussion:
[PLUG] Copying directories from one host to another
Rich Shepard
2018-11-10 00:03:51 UTC
Permalink
I want to copy /home and /opt from one host to another, including all
dotfiles (common in /home).

Operating within the destination directory would this the the optimal pair
of commands to use?

shopt -s dotglob
rsync -av salmo:/home/* ./

and changing the salmo directory to /opt after.

Regards,

Rich
Paul Mullen
2018-11-10 00:56:30 UTC
Permalink
Post by Rich Shepard
I want to copy /home and /opt from one host to another, including all
dotfiles (common in /home).
Operating within the destination directory would this the the optimal pair
of commands to use?
shopt -s dotglob
rsync -av salmo:/home/* ./
No need to set dotglob or use a splat in the source path. rsync will
find your dotfiles. The following should work just fine:

rsync -av salmo:/home/ .

The trailing slash in the source path tells rsync to copy the contents
of the directory into the destination path. Otherwise it would create
a new directory (home/) under the destination path.

The "dry run" option (-n) is your best friend when trying to figure
out a correct rsync command line. It'll show you everything that
would have happened, without actually making any changes.
--
Paul Mullen
Rich Shepard
2018-11-10 13:33:54 UTC
Permalink
Post by Paul Mullen
No need to set dotglob or use a splat in the source path. rsync will
rsync -av salmo:/home/ .
Thanks, Paul. I assumed this was sufficient as I've used those two options
before. I was not sure whether more options would be beneficial.
Post by Paul Mullen
The trailing slash in the source path tells rsync to copy the contents
of the directory into the destination path. Otherwise it would create
a new directory (home/) under the destination path.
Yeah, learned that years ago. :-)
Post by Paul Mullen
The "dry run" option (-n) is your best friend when trying to figure out a
correct rsync command line. It'll show you everything that would have
happened, without actually making any changes.
Good point.

Regards,

Rich
Rich Shepard
2018-11-10 18:11:03 UTC
Permalink
Do not see this on the mail list so I'm resending it.

Rich

---------- Forwarded message ----------
Post by Paul Mullen
No need to set dotglob or use a splat in the source path. rsync will
rsync -av salmo:/home/ .
Thanks, Paul. I assumed this was sufficient as I've used those two options
before. I was not sure whether more options would be beneficial.
Post by Paul Mullen
The trailing slash in the source path tells rsync to copy the contents
of the directory into the destination path. Otherwise it would create
a new directory (home/) under the destination path.
Yeah, learned that years ago. :-)
Post by Paul Mullen
The "dry run" option (-n) is your best friend when trying to figure out a
correct rsync command line. It'll show you everything that would have
happened, without actually making any changes.
Good point.

Regards,

Rich

Loading...