2

How I can backup(and restore) partition layout of the Disk along with file system types,UUIDs,labels,LVM partitions(Linux LVM) etc, plus with MBRs and VBRs etc but without actual files

I want to later restore it somewhere else and have identical filesystems and partitions and then restore files manually by my self

I need that layout backup to be small so I can't just make empty version of that partition and file systems and make raw image ...

Is there any way to do that?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208

2 Answers2

4

Looking at partimage is probably the best result; however, if you want to take it further; you probably need to construct something yourself. I don't know of any any tools that will exactly backup & restore EVERYTHING you want.

Partition table/block devices

Dumping MBR partition table:

sfdisk -d /dev/sd$X >$FILE

Restore MBR partition table:

sfdisk /dev/sd$X

Dumping GPT:

sgdisk -b $FILE /dev/sd$X

Restore GPT:

sgdisk -l $FILE /dev/sd$X

Show your block devices as a tree

lsblk

Logical block devices

LVM (can recreate PV, VG, LVM structure):

vgcfgbackup ... vgcfgrestore ...

Filesystems

Showing UUIDS & Labels:

blkid

Show xfs parameters

xfs_info /dev/sd$X$N

Show ext[234] parameters (look at the features line):

dumpe2fs -h /dev/sda1

Backup & Restore XFS metadata:

xfs_metadump -o /dev/sd$X$N FILE xfs_mdrestore FILE /dev/sd$X$N

robbat2
  • 320
  • 4
  • 10
  • `blkid` shows me UUIDs for partitions and filesystems but `sfdisk` does not include them, so they cannot be restored. This part is missing from the backup instructions here and it will prevent a system of restored files from booting. I'm in such a situation now. – ygoe Dec 12 '20 at 08:59
  • @ygoe newer sfdisk absolutely does list and restore UUID for GPT partitions, I just verified with util-linux-2.36.1. It does not restore filesystem UUIDs, but those you could already change w/ tune2fs etc. – robbat2 Dec 16 '20 at 06:07
0

I can only think of the dd command. The only problem would be changing the UUID (if used) on the /etc/fstab, which you can do on recovery mode if needed; or change it to a label/device before doing the backup.

Isaac
  • 159
  • 4