Solved rysnc issue with maintaining directory structures

Ok I know this is going to be simple, but I need some help.

I am attempting to copy all of the files within the following directory:

Old server /var/db/mysql/*.* to
new server /var/db/mysql/

However it's dropping /var/db/mysql inside the /var/db/mysql on the new server.

Here is the command I'm using:

rsync -aRvz -e "ssh -p 3333" root@111.22.33.456:/var/db/mysql/ /var/db/mysql/

I've tried it without the trailing slashes and with and it seems I still get the same results every time.

Any suggestions?
 
What happens when you use
Code:
rsync -aRvz -e "ssh -p 3333" root@111.22.33.456:/var/db/mysql /var/db/mysql/
Note that I left out only trailing hash on the old server but I left it on the new server.
 
The behaviour of using a trailing slash on the directory name is explained in rsync(1) under the heading USAGE:
Code:
[cmd]rsync -avz foo:src/bar /data/tmp[/cmd]

This would recursively transfer all files from the directory src/bar on
the machine foo into the /data/tmp/bar directory on the local machine.
The files are transferred in "archive" mode, which ensures that sym-
bolic links, devices, attributes, permissions, ownerships, etc. are
preserved in the transfer. Additionally, compression will be used to
reduce the size of data portions of the transfer.

[cmd]rsync -avz foo:src/bar/ /data/tmp[/cmd]

A trailing slash on the source changes this behavior to avoid creating
an additional directory level at the destination. You can think of a
trailing / on a source as meaning "copy the contents of this directory"
as opposed to "copy the directory by name", but in both cases the
attributes of the containing directory are transferred to the contain-
ing directory on the destination. In other words, each of the follow-
ing commands copies the files in the same way, including their setting
of the attributes of /dest/foo:

[cmd]rsync -av /src/foo /dest[/cmd]
[cmd]rsync -av /src/foo/ /dest/foo[/cmd]
You can experiment by using the --dry-run flag:
Code:
[adriaan@hercules]~[cmd]rsync -avRz --dry-run /home/adriaan/LOGS/  /tmp/[/cmd]
sending incremental file list
/home/
/home/adriaan/
/home/adriaan/LOGS/
/home/adriaan/LOGS/serial-log-1.txt
/home/adriaan/LOGS/serial-log-2.txt
/home/adriaan/LOGS/serial-log-2014-12-21_05:28
/home/adriaan/LOGS/serial-log-ELFerror.txt

sent 598 bytes  received 81 bytes  1358.00 bytes/sec
total size is 1932174  speedup is 2845.62 (DRY RUN)


[adriaan@hercules]~: [cmd] rsync -avc --dry-run /home/adriaan/LOGS/ /tmp[/cmd]
sending incremental file list
./
serial-log-1.txt
serial-log-2.txt
serial-log-2014-12-21_05:28
serial-log-ELFerror.txt
[snip]

sent 830 bytes  received 72 bytes  1804.00 bytes/sec
total size is 1932174  speedup is 2142.10 (DRY RUN)

[adriaan@hercules]~: [cmd]rsync -avc --dry-run /home/adriaan/LOGS  /tmp[/cmd]
sending incremental file list
LOGS/
LOGS/serial-log-1.txt
LOGS/serial-log-2.txt
LOGS/serial-log-2014-12-21_05:28
LOGS/serial-log-ELFerror.txt
[snip]

sent 843 bytes  received 73 bytes  1832.00 bytes/sec
total size is 1932174  speedup is 2109.36 (DRY RUN)
 
Thanks for following up. (Keep in mind that one day, someone might have the exact same problem, come across this thread, and be helped by that.)
 
Back
Top