LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-13-2017, 10:41 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
rsync not copying with umask permissions


I have an odd problem. I'm running the following rsync command as root:
[code]
rsync -v -r -t --delete --partial /OHPRSstorage/Acronis/workstations/ /mnt/localBackup/Acronis/workstations
[code]
a source file on /OHPRSstorage/Acronis/workstations/common/is:
Code:
-rw-rw----  1 ohprso ohprs 204154514432 2017-08-07 00:28 common_full_b182_s1_v1.tib
but after the rsync command the permissions are:
Code:
-rw-r----- 1 root root 204154514432 2017-08-07 00:28 common_full_b182_s1_v1.tib
root's umask is 0022

Why is rsync not creating the destination files with og+r per its umask?

Last edited by mfoley; 08-13-2017 at 10:55 PM. Reason: clarify title
 
Old 08-14-2017, 02:54 AM   #2
55020
Senior Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 1,307
Blog Entries: 4

Rep: Reputation: Disabled
That's how umask works. It only removes permissions, it doesn't add them. You might consider revisiting some basic Unix tutorials?
 
Old 08-14-2017, 04:10 AM   #3
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
What is it that you want it to do? If you want to replicate all file permissions, user/group ownership etc, then vrt flags alone won't do it. If that's your goal, then try the following flags:

-vaxAX --delete --partial
 
1 members found this post helpful.
Old 08-14-2017, 04:36 AM   #4
kjhambrick
Senior Member
 
Registered: Jul 2005
Location: Round Rock, TX
Distribution: Slackware64 15.0 + Multilib
Posts: 2,159

Rep: Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512Reputation: 1512
Good info IsaacKuo !

And if one uses and wants to preserve their HardLinks, then maybe add the -H flag as well:

Code:
rsync -vaxAXH --delete --partial ...
All these flags inply you'll be running as root ...

and as always:
Code:
man rsync
HTH

-- kjh
 
1 members found this post helpful.
Old 08-14-2017, 04:38 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,307
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by IsaacKuo View Post
then vrt flags alone won't do it. If that's your goal, then try the following flags:
Yes, it looks like the -a flag is needed here to get the expected results. Or at least the -p option is needed to save permissions and it is included in the -a option.

Code:
man rsync
 
1 members found this post helpful.
Old 08-14-2017, 11:23 AM   #6
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by 55020 View Post
That's how umask works. It only removes permissions, it doesn't add them. You might consider revisiting some basic Unix tutorials?
I don't think I agree with this statement. If I have umask 0022 and I `touch` a file, I get -rw-r--r--. In other words, it creates the file with o+r. It seems to me that rsync is *creating* files on the target directory (on the same computer) and in the absence of specify permissions it should create with the 0022 umask (but of course, it's not).

Quote:
Originally Posted by Turbocapitalist View Post
Yes, it looks like the -a flag is needed here to get the expected results. Or at least the -p option is needed to save permissions and it is included in the -a option.
I've found a solutions, but neither the -a nor -p option are what I want. If you'll notice in my OP the source file permissions were -rw-rw----, meaning that -a or -p would keep those permission and I still wouldn't have o+r. To do this, I use:
Code:
rsync -v -r -t --chmod=o+r,Do+x
The 'D' flag is special and indicated setting 'x' for directories.

This works, but still doesn't explain why rsync doesn't use the user's umask to create the target files (if -a -p or --chmod are not specified). I guess that's just the way rsync works, so I'll not worry about it.

Last edited by mfoley; 08-14-2017 at 11:24 AM.
 
1 members found this post helpful.
Old 08-14-2017, 11:55 AM   #7
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The umask is applied against whatever permissions the calling program requests. For new files, most programs, including touch, request 0666, so with a umask of 0022 the result is 0644. (Compilers that produce executable files generally request 0777.) The permissions that rsync requests for a new file are those of the source file, in this case 0660, and the result is 0640. The "-p" flag just causes rsync to ignore the umask and copy the source permissions exactly. Unless you use "--chmod", rsync never adds permissions that the source file did not have.
 
2 members found this post helpful.
Old 08-15-2017, 11:36 AM   #8
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by rknichols View Post
... Unless you use "--chmod", rsync never adds permissions that the source file did not have.
Good to know. Thanks.
 
  


Reply

Tags
perm, rsync



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
How to run Rsync with preserving Ownership, Permission, Group? lq_win Linux - Newbie 25 09-09-2016 05:54 PM
[SOLVED] Preserving JPEG Metadata Across Network with cp, rcp or rsync NoHoWarlord Linux - General 10 03-09-2015 01:12 AM
rsync not preserving owner and group graziano1968 Linux - Server 6 09-10-2008 07:52 AM
Preserving Permissions RemusX2 Linux - Software 2 07-10-2005 11:20 AM
Preserving permissions when using cp pilot1 Linux - General 2 08-16-2003 05:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:35 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