LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-08-2016, 09:57 AM   #1
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Rep: Reputation: Disabled
Question How to run Rsync with preserving Ownership, Permission, Group?


How to run Rsync with preserving Ownership, Permission, Group?

rsync -rtvz /home2/user1/ /home2/user1.backup

result:

root is the ownership of home2/user1.backup ?

what I want is user1 is still the owner of /home2/user1.backup with his permission and group..

please help
 
Old 09-08-2016, 10:11 AM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
To preserve ownership, perms and group: -opg

But usually you use -a, which implies -rlptgoD

Try man rsync for more options
 
Old 09-08-2016, 10:14 AM   #3
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
Hi...

I tried -a
also -aopg

still does not preserve ownership, group, and perms

please help
 
Old 09-08-2016, 10:15 AM   #4
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
-a equals: -rlptgoD

So with your 1st post example:
Code:
rsync -avz /home2/user1/ /home2/user1.backup
 
Old 09-08-2016, 10:39 AM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
Just run a chmod on /home2/user1.backup, you should only have to do it once.

What's happening is your source has a trailing slash, that means it doesn't copy /home2/user1, it copies everything inside of /home2/user1. And with rsync -r when the destination is an existing directory, it copies into the destination directory, without touching the directory itself at all.

All of this means that the way you're running the command, rsync is completely ignoring the permissions on both /home/user1 and /home2/user1.backup themselves, and only maintaining the permissions on the contents of these two directories.
 
Old 09-08-2016, 10:41 AM   #6
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
no it does not work ..the owner of /home2/user1.backup still guest!
 
Old 09-08-2016, 11:11 AM   #7
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 8 Jessie
Posts: 1,688
Blog Entries: 5

Rep: Reputation: 163Reputation: 163
I use something like:

rsync -vaxAX <source parent>/<source> <target parent>/

But depending on the circumstances sometimes special files still don't get set correctly-in particular, it doesn't work over nfs. For those stubborn special files, I use

cp -vax <source parent>/<source> <target>/

These are what I use to clone an entire OS, preserving permissions, ownership, groups, everything.
 
Old 09-08-2016, 12:14 PM   #8
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
it does not work

User1 is the owner of
/home/user1
And I want to rsync that folder (include all the permission and the owner)
To /home/user1.backup

The result is
/home/user1.backup was synchronized but the owner is guest??
It should be user1
 
Old 09-08-2016, 12:20 PM   #9
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
@suicidaleggroll gives explanation on post #5, please read it

Then chown User1 /home/user1.backup and be done with it
 
1 members found this post helpful.
Old 09-08-2016, 04:34 PM   #10
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Instead of this bullshit piecemeal code vomit, how about you tell us what you're really trying to accomplish?
NOT what you've done. What you want to accomplish.

home2?
Solution would be rapidly forthcoming or a another technique possible with some context of the bigger task.

"what I want" is a right now answer.

Last edited by Habitual; 09-08-2016 at 04:36 PM.
 
Old 09-08-2016, 06:14 PM   #11
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
Hi @Habitual

Thank you,
I have more than 100 VIP's mailbox that required to be backup every night to a folder in the same machine, source Maildir is under /Home2/Users/* and the target is under /Home3/Users/*.

How to backup their mailbox with their original ownership, permission, group?

Need your advise.

Regards
 
Old 09-08-2016, 06:34 PM   #12
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 8 Jessie
Posts: 1,688
Blog Entries: 5

Rep: Reputation: 163Reputation: 163
Quote:
Originally Posted by lq_win View Post
I have more than 100 VIP's mailbox that required to be backup every night to a folder in the same machine, source Maildir is under /Home2/Users/* and the target is under /Home3/Users/*.

How to backup their mailbox with their original ownership, permission, group?
Use this:

Code:
rsync   -vaxAX   /Home2/Users   /Home3/
This will recursively replicate Users from /Home2/Users to /Home3/Users, preserving original ownership, permission, group, etc. In particular, it will replicate the original ownership/permission/group of the "Users" folder itself also.
 
Old 09-08-2016, 06:48 PM   #13
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
I also tried -vaxAX but the ownership of copied folder still guest
 
Old 09-08-2016, 06:51 PM   #14
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,387

Rep: Reputation: 397Reputation: 397Reputation: 397Reputation: 397
And what is ownership inside copied folder?
 
Old 09-08-2016, 06:52 PM   #15
lq_win
Member
 
Registered: Jul 2015
Posts: 46

Original Poster
Rep: Reputation: Disabled
All the ownership are guest
 
  


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
rsync - permission denied (13) on Centos 6.5 - even when run as root Kernel Fergus Linux - Server 3 03-06-2014 10:54 AM
File & Folder Permission and Ownership permission error in Cloud storage. rhcekumaran Linux - Newbie 3 06-14-2013 05:41 AM
mkdir throws Permission Denied error in a directoy even with root ownership and 777 permission surajchalukya Linux - Security 14 09-03-2012 09:34 AM
rsync not preserving owner and group graziano1968 Linux - Server 6 09-10-2008 08:52 AM
Preserving date and ownership when untar ? talat Linux - Software 1 02-09-2006 05:07 PM


All times are GMT -5. The time now is 12:13 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration