0

I want to create a bootable backup image/clone of my centos7 server "A" having software raid partitions and use this backup to create new servers with same configurations.

my partitions are

sda
--> sda1
----> md120 /
--> sda2
----> md121 swap
--> sda3
----> md122 /boot
--> sda4
----> md123 /var/images

sdb
--> sdb1
----> md120 /
--> sdb2
----> md121 swap
--> sdb3
----> md122 /boot
--> sdb4
----> md123 /var/images

sdc 

I have used dd command to take backup of sda parttion (containing boot and swap, root and /var/images )

dd if=/dev/sda of=/dev/sdc bs=512 conv=noerror,sync

but when i restore the image on another server "B" (bare metal with same configuration) sda partition.

I was hoping that i will automatically boot up the server and raid sync will start on the other sdb drive.

But unfortunately it is not working.

Could anyone please suggest me the way to take backup of software raid partitions. And do i need to take backup of both drive ?

Thanks

Quantim
  • 1,358
  • 10
  • 15
  • I'm not aware of your constraints, but I would strongly suggest that you study the kickstart install method, followed by an ansible playbook to configure your system. You will save time, believe me. – Chaoxiang N Feb 18 '19 at 10:01

2 Answers2

1

Your approach is wrong, first of all an idea to do backup of swap is bad.

Anyway, IIUC you want to have a kind of template for your servers. I would suggest to use kickstart with install option with liveimg parameter - this way you could create an image with all your files which would be "populated" into your new installed server during kickstart-based unattended installation.

See: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax#idm140037269828320

If you do not want to have 100% equal machines, just use kickstart with nfs or url parameter pointing to either public Centos repo or your mirror.

You can create all storage kung-fu in kickstart, see documentation.

Jiri B
  • 547
  • 2
  • 15
0

To create similar servers with an unattended installation, you should look into kickstart like the other answers suggest.

However, if you want to go the dd way, the idea is to create/restore an image of each RAID device rather than the underlying disks or partitions. You would also have to create an image of the boot/partition area of each disk. To restore the backup, you boot the target system with a "live" Linux system (e.g. http://www.system-rescue-cd.org/), then restore the boot/partition areas, create and assemble the RAID devices and finally restore the backup images to the RAID devices.

Your original approach of creating a full clone of the sda drive could also work (although it's not very efficient). But on the new server you have to manually create the partitions on the 2nd drive and then add them to the RAID arrays to start the re-sync.

Radu Rendec
  • 141
  • 2