I'm having a little rsync problem. I am trying to move data from one server to the next using rsync. The data needs to retain file owner and permission settings. The files in question are not owned by me, but my account (on both servers) does have sudo access.
For example, I want to copy /var/www from server1 to server2. All files are owned by user www-data. My user account on both servers is
does not work, because sander@server2 cannot write to /var/www and cannot change the uid/gid to www-data.
Does not work. sander@server1 cannot read /var/www.
How do I solve this?
asked 09 May '10, 20:09
I found the following article, http://crashingdaily.wordpress.com/2007/06/29/rsync-and-sudo-over-ssh/ and one of the solutions seems to meet your needs (although I haven't tested it).
If you ran the following on Server2:
This line seems to enable the 'sudo tunnel' if you will:
and then this the transfer causing rsync to run under sudo (I added the 'u' as then it will only copy over files that are newer or don't yet exist):
answered 09 May '10, 20:54
You may want to try this!
You may want to create a directory under your home directories under both servers;
server1$ sudo rsync -av /var/www/ sander@server1:~/www/
scp sander@server1:~/www/ sander@server2:~/www/*
server2$ sudo rsync -av sander@server2:~/www/ /var/www/
This all depends on the permissions you have access to the directory /var/www/ on both servers; server1 & server2.
answered 09 May '10, 20:51