rsync backup root files


 
Thread Tools Search this Thread
Operating Systems AIX rsync backup root files
# 1  
Old 01-25-2012
Data rsync backup root files

Hi,

I am trying to use rsync utility through ssh to synchronize some root files of 2 servers.
I have a rsyncusr user in each server. I configured ssh with no password. I set NOPASSWD in the /etc/sudoers file:
Code:
rsyncusr ALL= NOPASSWD:/usr/bin/rsync

In order to make rsync able to sudo and be able to sync root files from one server to other server.

So far, I was not be able to transfer the files preserving the permissions (owner, group, etc).

To illustrate with an example. I have a file in the remote host dev3test:
Code:
-rw-r-----    1 root     system     12615680 Jan 19 16:27 dev3test

I have 2 servers:
Local: roidev
remote: roidev3

First scenario:
If I try from the local host to pull the file from the remote host to the local host:
Code:
rsyncusr@roidev-/dbbackup $ rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" rsyncusr@10.144.206.84:/deletefs/dev3test

The file is transferred to the local host with the following permissions :
Code:
rw-r-----    1 rsyncusr db2iadm1   12615680 Jan 19 16:27 dev3test

The owner and the group is changed.

Second scenario:
If I try from the remote host to push the file from the remote host to the local host:
Code:
rsyncusr@roidev3-/home/rsyncusr $ rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" /deletefs/dev3test rsyncusr@10.144.206.20:/dbbackup

I got the following error
Code:
rsync: send_files failed to open "/deletefs/dev3test": Permission denied (13)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1042) [sender=3.0.7]

Third scenario:
Loggin as a root user in the local host or in the remote host, executing the same commands:
Code:
root@roidev-/dbbackup# rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" rsyncusr@10.144.206.84:/deletefs/dev3test /dbbackup
rsyncusr's password: 

root@roidev3 / # rsync -a -e "ssh" --rsync-path="/usr/local/sudo-1.6.6/bin/sudo rsync" /deletefs/dev3test rsyncusr@10.144.206.20:/dbbackup
rsyncusr@10.144.206.20's password:

I can get the transfer file with the right permissions, but I am requiring for rsyncusr password.
Code:
-rw-r-----    1 root     system     12615680 Jan 19 16:27 dev3test

I can not loggin as root through the network, only I can do sudo.


I would like to know if there is a way to transfer root files preserving permissions as a different user and without password, using rsync with ssh.

thanks in advance
Samalogo

Last edited by zxmaus; 01-26-2012 at 12:26 AM.. Reason: please use code tags rather than colors - that saves us from having to use sunglasses to read your post
# 2  
Old 01-25-2012
Your 3rd scenario seems to be better. Its just that you have to setup ssh key sharing for the rsyncusr. That should work.

Another option would be to set SGID bit on the folder on the local machine where the backup is getting stored. The owner group of the directory would be "system" and you may add root as the owner. Then, you can setup ACL to explicitly allow access for rsyncusr. The files written would be with "system" as the owner group. But, still "rsyncusr" will be the owner of the file.

I would suggest, you create home directory (if it's not already setup) for the rsyncusr in the remote machine and put the ssh public key in /home/rsyncuser/.ssh/authorized_keys
# 3  
Old 01-26-2012
Thx for replying me.

Actually, I setup in both servers the ssh keys. So if I am logging in one server as a rsyncusr and I prompt the ssh command to connect with the other server: "ssh rsyncusr@hostname", I can loggin without ask me for password in both ways. But in the third scenario I am logging as a root, so the system ask me for the rsyncusr password.

Or there are something what I am missing?

Thanks for your help
Samalogo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Backup solution using rsync

Hello All, I am looking at a fast way to script some backups. I am looking at using rsync to do the leg work. I am having a hard time conceiving a script though. I have a tree with subfolders within subfolders. I was looking at the /xd option to parse the tree. Directory of k:\ ... (4 Replies)
Discussion started by: jvamos
4 Replies

2. Shell Programming and Scripting

Rsync better use for backup

Hello, I have a list of working directory in a remote computer acesssible through ssh and the same directory structure in my home directory of my laptop. I sometimes work on both my laptop and my this other computer. I usually use Rsync this way to synchronize files rsync... (5 Replies)
Discussion started by: ajayram
5 Replies

3. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

4. Shell Programming and Scripting

rsync backup and recovery options

Hi, Do we have any options in rsync to recover files from the backup? Please share your thoughts. Thanks in advance. (0 Replies)
Discussion started by: MVEERA
0 Replies

5. UNIX Desktop Questions & Answers

Help with excluding .Trashes in an rsync backup

I'm using this script to backup an external hdd to another external hdd - rsync -aE --delete --exclude Volumes/Disk\ A/.Trashes "/Volumes/Disk A" "/Volumes/Disk A Backup"The source drive being "Disk A", and the drive I wish to backup to being "Disk A Backup". I'm constantly getting this error,... (4 Replies)
Discussion started by: Orbient
4 Replies

6. Shell Programming and Scripting

Rsync backup

How do i use Rsync yo pickup only new or modified files from source? I am using rsync -ravzpotu --delete-excluded but sometimes it goes thru all files again (5 Replies)
Discussion started by: sprool
5 Replies

7. Shell Programming and Scripting

Does rsync has option to backup only new updates files on different dir

Hi I would like to ask if rsync has an option of backing up the new or updated files on different destination dir( only the new or updated files will be copied to the a different dir) just like option --backup-dir but this is for backup files. Thanks for any response. (1 Reply)
Discussion started by: jao_madn
1 Replies

8. Cybersecurity

Permissions for Backup user to rsync files

I've got a new MythTV box at home and figured it would be a great opportunity to use it to do daily mirrors of my mysqlbackup directory (let's say /mysqlbackup/backups) and my website at /usr/local/apache/htdocs and below. I figured it would be a best practice NOT to use a root login but to... (0 Replies)
Discussion started by: dheian
0 Replies

9. Shell Programming and Scripting

rsync script for synchronisation and backup

hello, i need to modified my synch/back scripts.... i want that this script only syncro folders in destinationfolder. f.e. when in destination are two folders 1) admin 2) users but in SOURCE are three: 1) admin 2) users 3) antivirus the script should only increnmential sync the... (0 Replies)
Discussion started by: onkeldave
0 Replies

10. Shell Programming and Scripting

Rotating snapshot backup using rsync

I want to take daily backup(11pm) of /var/www to /mnt/bak excluding /var/www/videos and /var/www/old. HOW to implement a rotating snapshot method, so that i can have multiple(say 4) automatically rotating backups. (0 Replies)
Discussion started by: proactiveaditya
0 Replies
Login or Register to Ask a Question