[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Restore backup to KVM

On Sun, Sep 24, 2017 at 10:58:42AM +0200, solitone wrote:
> On 22/09/17 21:38, Reco wrote:
> > 2) Your backup is made by rsync(1) or tar(1).
> > 
> > Make yourself a file representing virtual machine disk.
> > Apply parted/fdisk/whatever to make appropriate number of partitions
> > inside it. Create filesystems.
> > Mount these somewhere, invoke rsync(1)/tar(1) as needed.
> Ok, I've done all these steps.
> > Fix extended file attributes, capability labels, SELinux labels if any
> > etc. By hand, that is.
> This is hard, since I'm unaware of what files have extended attributes. For
> instance, I've just found out that /media/solitone has an ACL, but I would
> need to extract the information for all files involved in a list and back it
> up, in order to restore it later on manually.

ACLs are easy. Even tar(1) knows them.
It's things like these that give you headache:

$ /sbin/getcap /bin/ping
/bin/ping = cap_net_raw+ep

# lsattr /etc/resolv.conf
----i---------e---- /etc/resolv.conf

# getfattr -d /var/log/messages
# file: var/log/messages
user.name="main system log"

# ls -alZ .bashrc
-rw-r--r--. root root system_u:object_r:admin_home_t:s0 .bashrc

If you have any of these in your source system, but don't have in target
one - your backup is invalid, consider changing tool you're using.
Note that these are just the examples, there can be other files like

> > Fix boot/grub/grub.cfg or whatever configuration file of bootloader
> > you're using.
> I don't know how to do this. I have to admit I never really understand GRUB.
> I've always relied on the configuration steps that debian automatically
> performs. Have you got a simple document that could guide me?

Cheat it then and run QEMU like this (I don't know what's your root
filesystem is called, you may need to replace sda2 with something else):

qemu-system-x86_64 -hda <your_qemu_file_here> \
	-kernel <restored_kernel> \
	-initrd <restored_initrd> \
	-append "root=/dev/sda2 ro init=/bin/bash"

If it boots *and* mounts everything it should - terminate QEMU and run
it like this and run update-grub from the inside:

qemu-system-x86_64 -hda <your_qemu_file_here> \
	-kernel <restored_kernel> \
	-initrd <restored_initrd> \
	-append "root=/dev/sda2 ro"

Don't forget to unmount filesystems from your host OS before running


Reply to: