Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

How to clone volume keeping permissions and restore it

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
coppolino97
Posts: 117
Joined: 2018-06-05 15:23
Location: Italy
Has thanked: 2 times

How to clone volume keeping permissions and restore it

#1 Post by coppolino97 »

Hi all,
I have a server that has got RAID hardware.
There are two RAID hardware:
the first one is RAID 5 (OS)
the second one is RAID 0 (there are some data volume)

I know that RAID 0 is really dangerous, so I need to change this configuration created in the past.
There is a Linux partition on this server that is located on RAID 0, so I must copy all RAID 0 data partition before.

I must keep files/folders permissions when I will restore this data clone/data backup.

How can I clone all partition with all file permissions?

Should I configure again /etc/fstab file with new volume ID? Right?

Thanks so much!
Lenovo T460 | 8Gbyte of RAM | Intel core i5 | SSD 250GB | Debian 12

seeker5528
Posts: 61
Joined: 2021-09-18 00:37
Been thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#2 Post by seeker5528 »

Rsync has options for preserving permissions if the available space makes copy of individual files preferble to partition cloning. I don't know if you have an option while partitioning to specify a UUID to use, if yes you could give the new partition the same UUID, if no it would be a matter of preference on whether you change the UUID in fstab to match the partition or change the UUID of the partition to match fstab.

If your drive device that will hold the data while you reconfigure the raid is large enough you could use partclone to clone the entire partition device to device and the partition would have the same UUID and label. As long as you don't boot/reboot the system while they both have the same UUID there shouldn't be anything weird happening.

Or if the new device will also be equal or larger, you could clone the drive device to a file and clone the file back to the new drive device and the new device would end up with the same UUID without having to worry about two devices having the same UUID.

coppolino97
Posts: 117
Joined: 2018-06-05 15:23
Location: Italy
Has thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#3 Post by coppolino97 »

Hi @seeker5528 ,
In my case I don't think that I will have option to partitioning the RAID volume that I am going to change from RAID 0 to RAID 5.

On this RAID volume there aren't too much data.
The final volume is going to be smaller because RAID 5 capacity is smaller than RAID 0 using the same hard drives, but there is going to be faulty tollerance.
I am sure that I can restore the original data quote inside the new RAID 5.
RAID 5 is going to have enough space to store all server data.

Could generate trouble if the system is going to see a new UUID?
Isn't sufficient just restore all server data without loosing owner and permissions?

How can I copy and restore data without loosing owers/permissions?

Best regards
Lenovo T460 | 8Gbyte of RAM | Intel core i5 | SSD 250GB | Debian 12

CwF
Global Moderator
Global Moderator
Posts: 2680
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 196 times

Re: How to clone volume keeping permissions and restore it

#4 Post by CwF »

coppolino97 wrote: 2021-09-29 20:18 How can I copy and restore data without loosing owers/permissions?
perhaps fsarchiver to an off location, arrange raid's, restore.
on true hardware raid it's a partition like any other I believe, so imaging the partition to a temp file, then to the final setup. This might work on software raid, don't know.

seeker5528
Posts: 61
Joined: 2021-09-18 00:37
Been thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#5 Post by seeker5528 »

coppolino97 wrote: 2021-09-29 20:18 Could generate trouble if the system is going to see a new UUID?
Isn't sufficient just restore all server data without loosing owner and permissions?

How can I copy and restore data without loosing owers/permissions?

Normally the UUID only gets used to make sure the partition gets mounted normally even if device name changes. Any other use of UUID would be optional. Backup or other maintenance would be prime candidates, but these would be things you installed and setup to use the UUID, scripts you created that use the UUID, etc....

I rarely use rsync, but this would be one of those use cases, usually the archive option works for my needs, but I do review the man page or use the help option beforehand to make sure that is what I want to do.

From the man page

-a, --archive
This is equivalent to -rlptgoD. It is a quick way of saying you want recursion and want to preserve almost everything (with -H being a notable omission). The only exception to the above equivalence is when --files-from is specified, in which case -r is not implied.

To review the options do 'rsync --help' for longer descriptions and examples 'man rsync'

The filesystem you copy to has to have the ability to store the permissions, no FAT variants and no NTFS.

coppolino97
Posts: 117
Joined: 2018-06-05 15:23
Location: Italy
Has thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#6 Post by coppolino97 »

Hi,

@CwF,
perhaps fsarchiver to an off location, arrange raid's, restore.
Thanks, I did not know this tool. It is really interesting!

@seeker5528
Thanks for your suggestions about rsync

Best regards :D
Lenovo T460 | 8Gbyte of RAM | Intel core i5 | SSD 250GB | Debian 12

coppolino97
Posts: 117
Joined: 2018-06-05 15:23
Location: Italy
Has thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#7 Post by coppolino97 »

Should fsarchive tool work with LVM too?

In my case, I have this configuration. I noted that in the past, old owner configured LVM.

Code: Select all

sdb                                     8:16   0   7.3T  0 disk
└─sdb1                                  8:17   0   7.3T  0 part
  └─SysVol02-LV_ServiceDataDisk (dm-0) 252:0    0   7.3T  0 lvm  /srvdata
Thanks for your help!
:D
Lenovo T460 | 8Gbyte of RAM | Intel core i5 | SSD 250GB | Debian 12

seeker5528
Posts: 61
Joined: 2021-09-18 00:37
Been thanked: 2 times

Re: How to clone volume keeping permissions and restore it

#8 Post by seeker5528 »

I don't use LVM, it does give you additional options for backup and restore.
https://devconnected.com/lvm-snapshots- ... -on-linux/

SystemRescue is my goto live disk option for cloning, data rescue, chrooting my installed linux system on the odd occasion. They give an example shell script for creating an LVM snapshop, then using fsarchiver to back the files up from the snapshot.

https://www.system-rescue.org/lvm-guide ... -with-LVM/

I have not use fsarchiver it looks like a good option, it is backing up the files and permissions instead of working at the partition level so restoring to a smaller space is not an issue.

Since it is backing up the files and not working at the partition level you would still have to make sure the UUID of the partition and the UUID in fstab match.

Post Reply