I'm just trying to copy a directory from one home server to another, both running Ubuntu (9.04 and 9.10), using rsync. The trouble I'm having is that some of the files in the directory (and subdirectories) are owned by root. The main administrator account on both machines is 'ben', so running this on the old server:
rsync -v -u -a -p -t -rsh=ssh --stats --progress source/ ben@newserver:/dest
Prompts me for ben@newserver's password, copies source/ but all the permissions are 'ben' at the new destination. Running this using sudo means I have access to root's files, but on the other end ben can't write them as belonging to root. Sending to root@newserver asks for root's password, which Ubuntu doesn't give you.
Can anyone explain simply how to do this? Thanks :)
You can set up SSH keys, and place your public key in root's
~root/.ssh/authorized_keys2
file onnewserver
. That way you can do the entire process as root.Alternativly you can set root's password via:
But SSH keys are more secure and (IMHO) more convenient.
You can use the
--rsync-path
option to runsudo rsync
on the remote machine; I suspect you'll have to give theben
user passwordless sudo privileges to runrsync
, as the chances ofrsync-path
passing the password prompt back to the source machine are slim.In order for rsync to maintain all file ownership/permissions attributes it need to be running as root at the end that is being written to. If you are only root at one end, this needs to be the writing end, so you would need to do
while logged in as root on the new server.
The
--fake-super
option can be useful when sending files to a backup location where you do not have root access (and when getting the files back again afterwards) but that won't be applicable here without a little extra mucking about (rsyncing to an intermediate location on either server with that option, then rsyncing to the final destination with it too).The other options, as already mentioned, is to give your user at the writing end passwordless access to rsync as root in your sudo config.