How to backup hard disk removed from RAID volume

How to backup hard disk removed from RAID volume

After migrating a RAID volume to new disks it’s handy to keep a full partition backup around. This can be done either by keeping the data on the former drives or, if those need to be re-purposed for some other task, by making a backup image of the volume.

For backup purposes it is safer to (re)mount the array off (at least) one of the previous disks and backup the resulting RAID volume. 

Start off by viewing info about the stored volume (to identify if it is the correct one):

mdadm --examine /dev/sdX1

As the disk was previously a member of a RAID volume which still exists on the system the UUIDs will collide and mdadm will refuse to mount this disk. To bypass we’ll need to assign a new UUID on volume reassembly (this will make the disk to no longer be recognised as belonging to the existing volume):

mdadm --assemble /dev/md127 --update=uuid /dev/sdX1

We’ll continue with the image creation. For this we can use partclone, a handy smart backup utility which is capable of recognizing multiple filesystem structures and then save only used data. Partclone is available for CentOS in the EPEL repo.

partclone.extfs -c -s /dev/md127 -o /data/outputfile.img

-c – tell partclone to clone (image) the source
-s device – specify the source partition
-o file – specify the backup output file; use -O (uppercase) to overwrite an existing file 

Once the backup is done, remember to stop the volume:

mdadm --stop /dev/md127

And finally move the backup file to a safe location.

If you notice that the md device gets assembled as read-only, check that the disks were not already claimed by dmsetup by running:

dmsetup table

If the devices that we want assembled are listed, they can be removed (after ensuring any array(s) using them is stopped) with:

dmsetup remove dm_device_name

Sources: (1), (2), (3), (4)

Leave a Reply