LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-15-2009, 12:11 PM   #1
gael
Member
 
Registered: Aug 2008
Posts: 41

Rep: Reputation: 15
inconsistent behavior of rsync for backup


Hi there,

I have a behavior I do not understand concerning a backup we are doing using rsync.

Basically the command we are using to do the backup is the following:

Quote:
rsync -uav --exclude-from "./toexclude.general" $USERNAME@$SERVER:/ $BACKUP_LOCATION/.
The script works OK and gather the data from the server.

The problem I am having is that: in the backed up data, the uid and gid are root.root whereas it should not be.
For instance the /etc/nagios2 folder does not have the correct permissions.

So I have tried to manually transfer the /etc/nagios2 folder using the exact same syntax and ... the uid/gid are all OK.

I do not understand and I have already spend a part of my day working on it...

If you need any more information please let me know.

Thank you very much in advance for your kind help!

Cheers...
G.
 
Old 04-16-2009, 04:31 AM   #2
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Hi all,

I do not mean to be a pain but having a point of view or some help would be really nice to help me troubleshoot the problem...

Thanks in advance!

Gael
 
Old 04-16-2009, 04:39 AM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
What user are you running the script as and the manual command? the -o and -g options (both implied by -a) require root.

Edit - who is $USERNAME as well

Last edited by billymayday; 04-16-2009 at 04:49 AM.
 
Old 04-16-2009, 04:41 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
try to add
Code:
--times --perms
to preserve the file timestamps and permissions
 
Old 04-16-2009, 04:44 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
They are both implied by -a as well
 
Old 04-16-2009, 05:19 AM   #6
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
First of all, thanks for your replies

Quote:
Originally Posted by billymayday View Post
What user are you running the script as and the manual command? the -o and -g options (both implied by -a) require root.

Edit - who is $USERNAME as well
The cron is run by the user: root

The manual command I am using is the same as the one I am using in cron.

$USERNAME=root


One more precision I am writing the backup on a Samba share (to be more precise, this is a Windows share mounted using CIFS).
 
Old 04-16-2009, 05:34 AM   #7
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
So does the source even have linux ownerships? I assume that you are running the manual command as uid/gid? Try running it manually as root - I suspect you'll get the cron result.
 
Old 04-16-2009, 06:25 AM   #8
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Well when the command is run manually (as root) the permissions and ownership are all good.
But as soon as cron runs it, everything is owned by root and the permissions are 777 on folders and rwxrwSrwt on files...
 
Old 04-16-2009, 08:44 AM   #9
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
How did you enter it into cron?
Both the source and remote usernames must be root for all permissions to be saved. If the source user is not root then some files will not be able to be read. If the dest user is not then it will not be able to set permissions & ownership on the destination of anything the user does not own.
 
Old 04-16-2009, 09:09 AM   #10
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
I am writing the backup on a Samba share (to be more precise, this is a Windows share mounted using CIFS).
This is your problem.

A windows filesystem has no concept of "Ownership" or "Group".

So when you retrieve the files from your windows filesystem, linux doesn't know who they should belong to, so they are assigned to root.

If you want to use rsync make sure the destination for the backup is a linux filesystem.

If you used tar to make to backup your files, you could save the resulting .tgz file to a windows filesystem, and permissions, groups etc. would be intact when you untarred it, because that's the way tar works.
 
Old 04-16-2009, 09:27 AM   #11
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
Quote:
This is your problem.

A windows filesystem has no concept of "Ownership" or "Group".
Hmm, really? Sure, if it's FAT. But NTFS has some concept of that; I use cygwin on Windows (NTFS drives) after all.
 
Old 04-16-2009, 09:53 AM   #12
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by AlucardZero View Post
How did you enter it into cron?
Both the source and remote usernames must be root for all permissions to be saved. If the source user is not root then some files will not be able to be read. If the dest user is not then it will not be able to set permissions & ownership on the destination of anything the user does not own.
Here is the cron.
Then the backup script contains the rsync command...

30 18 * * * root cd /root/backupscripts/; ./backup.xen01.sh;
 
Old 04-16-2009, 09:55 AM   #13
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by tredegar View Post
This is your problem.

A windows filesystem has no concept of "Ownership" or "Group".

So when you retrieve the files from your windows filesystem, linux doesn't know who they should belong to, so they are assigned to root.

If you want to use rsync make sure the destination for the backup is a linux filesystem.

If you used tar to make to backup your files, you could save the resulting .tgz file to a windows filesystem, and permissions, groups etc. would be intact when you untarred it, because that's the way tar works.

So why does it work when I run it manually? The permissions and ownership are all OK...


Good idea for tar (or maybe star), if this rsync thingy is still causing me trouble, I will take this solution...

Cheers
G.
 
Old 04-17-2009, 06:14 AM   #14
gael
Member
 
Registered: Aug 2008
Posts: 41

Original Poster
Rep: Reputation: 15
Hi all,

Do you have any more idea about this problem?

Please let me know. Much appreciate!

Gael
 
Old 04-17-2009, 12:39 PM   #15
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Quote:
So why does it work when I run it manually?
I am getting confused here. Please check these statements very carefully:

You are using a script to rsync files to a windows partition and then you later copy them back to linux.

When you run the backup script from a cron job, it fails to restore groups and ownerships ( and permissions? )when the files are copied from the windows filesystem back to linux.

When you run the script as (which user?) what was the exact command you used? [ history may help you here ] then the files are copied to the windows filesystem and then can be restored to the linux filesystem, and the groups and ownerships ( and permissions? ) are correct (I think this is not possible, but stand to be corrected, and don't have an NTFS filesystem to play with).

- * -

Now some Qs:

Please post your backup.xen01.sh script.

Quote:
So I have tried to manually transfer the /etc/nagios2 folder using the exact same syntax and ... the uid/gid are all OK.
Where did you "transfer the /etc/nagios2 folder" to? Was it a windows filesystem or a linux one?

While you think about those statements and Qs, please try some experiments:

As the user yourself create a directory in your username's home and put some files in it.

Try setting the permissions of the files in that directory to something strange like 733

As root, rsync that directory (belonging to the user yourself) to the windows filesystem.

Now restore it to root's home directory (/root) as the user root.

Is it still marked as being owned by yourself, or root?

Are the file permissions the same?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
dhcpd inconsistent behavior designator Linux - Networking 0 02-13-2009 12:54 PM
Udev inconsistent behavior. jmoody Linux - Software 1 08-07-2008 12:50 PM
Using RSync to backup a secondary off-site backup server pezdspencer Linux - Software 4 06-29-2007 03:40 PM
inconsistent bash behavior? kornelix Linux - Software 1 12-15-2005 11:06 AM
Strange, inconsistent BIND 9 behavior.... registering Linux - Networking 1 06-18-2004 04:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration