Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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...
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.
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.
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;
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...
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.