rsync using ssh via a sudo command
My main goal for this is, I was migrating from an old server to a new BSD server. In order to make preservation of user accounts,
I manage it with this command below using rsync tool to transfer or copy the files.
"rsync -p -o -g -r -a -v -e "ssh -l normaluseraddedviasudoers" --rsync-path "sudo rsync" --delete oldserver.com:/home . --log-file=/tmp/rsynclogs.txt "
-p means to preserve the permission, -o means to preserve the ownership, -g means to preserve the group.
-r means to recurse into ts sub-directories, -a means to archive them, -v means to use the verbose mode, -e specifies the remote login to use. With --rsync-path, it makes how to run rsync which this means like run the rsync via sudo or via root.
Now, I am able to copy all the files under /home directories without prior chmod afterwards when you are on the new server. It makes the rsync set everything for you and not worrying if the files has been able to copy or not it's because you might not copy everything because files/directories was not able to read because the user has no permission. With that command, that will help you solve your problem.
Note: You must add the normaluseraddedviasudoers with no password, that is:
Let say you are on the oldserver shell issue
$root@host > visudo
then locate root, and add it below the line
normaluseraddedviasudoers ALL = NOPASSWD: ALL
I manage it with this command below using rsync tool to transfer or copy the files.
"rsync -p -o -g -r -a -v -e "ssh -l normaluseraddedviasudoers" --rsync-path "sudo rsync" --delete oldserver.com:/home . --log-file=/tmp/rsynclogs.txt "
-p means to preserve the permission, -o means to preserve the ownership, -g means to preserve the group.
-r means to recurse into ts sub-directories, -a means to archive them, -v means to use the verbose mode, -e specifies the remote login to use. With --rsync-path, it makes how to run rsync which this means like run the rsync via sudo or via root.
Now, I am able to copy all the files under /home directories without prior chmod afterwards when you are on the new server. It makes the rsync set everything for you and not worrying if the files has been able to copy or not it's because you might not copy everything because files/directories was not able to read because the user has no permission. With that command, that will help you solve your problem.
Note: You must add the normaluseraddedviasudoers with no password, that is:
Let say you are on the oldserver shell issue
$root@host > visudo
then locate root, and add it below the line
normaluseraddedviasudoers ALL = NOPASSWD: ALL
Comments