You are not logged in.

#1 2013-10-02 15:36:01

jayflo
Member
Registered: 2013-09-06
Posts: 33

[Solved] Restore system from backup using rsync

I am thinking about installing Windows on my computer and I know it work's better to install Windows first, then arch.  That being said, I will likely reformat my system, install windows and then reinstall arch.  I've made many configurations that I would like to keep but not have to re-implement (it takes a while to set things up!) once I have the fresh arch install.  I know from https://wiki.archlinux.org/index.php/Fu … with_rsync that I can use:

sudo rsync -aAXv /* /path/to/backup/folder --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}

in order to backup all important parts of my system.  Before doing any reformatting I will run this script to backup my system to an external drive.  However, after I have reformatted, installed windows and then arch, what is the correct/efficient way to put the backup files (on the external drive) back into the newly installed system?  Even if I set up the partitions (associated to arch) during installation in exactly the same way (albeit they would be smaller since Windows would now occupy some space), I'd imagine that the command:

sudo rsync -aAXv /path/to/backup/folder/on/external/drive/* / 

would cause some epic failure?  Even if I modified the UUID's in the fstab before rebooting?  Would this strategy work if I only rsync'ed a subset of the backup files contained in the external drive (e.g. /home, /etc, /var, ...)?  If another strategy, apart from rsync, is best, please let me know.  Thanks for your help!

Last edited by jayflo (2013-10-02 22:49:57)

Offline

#2 2013-10-02 15:45:09

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Solved] Restore system from backup using rsync

Yes, it should work, once you fix configs in /etc and bootloader. Arch doesn't have any sort of artificial anti-piracy protection that would get in the way. I did that a few months ago, although i used cp -a instead of rsync.

Last edited by kaszak696 (2013-10-02 15:50:33)


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#3 2013-10-02 16:20:21

jayflo
Member
Registered: 2013-09-06
Posts: 33

Re: [Solved] Restore system from backup using rsync

kaszak696 wrote:

Yes, it should work, once you fix configs in /etc and bootloader

Which files need to be changed?

Offline

#4 2013-10-02 17:39:40

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Solved] Restore system from backup using rsync

jayflo wrote:
kaszak696 wrote:

Yes, it should work, once you fix configs in /etc and bootloader

Which files need to be changed?

Definitely /etc/fstab to accommodate your new partition table, and fix root= option for the kernel in your bootloader configuration. That's the minimum. Regenerating the bootloader will also be needed, wiki has all the necessary instructions for that.


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#5 2013-10-02 22:49:33

jayflo
Member
Registered: 2013-09-06
Posts: 33

Re: [Solved] Restore system from backup using rsync

From what you're saying, it seems like the best way to go about it would be to:

1) rsync everything except /boot and /etc/fstab
2) modify /etc/fstab as needed (basically change UUID's on backup version)
3) generate new /boot/grub/grub.cfg using grub-mkconfig
4) restart

This should apply all the mount options/kernel parameters correctly while not messing up any other files.  Thanks for the help.

Offline

#6 2013-10-02 22:53:53

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [Solved] Restore system from backup using rsync

No. You need to rsync /boot. Otherwise you will have no kernel to boot! rsync /boot but make sure you generate grub.cfg *after* you rsync so it will overwrite the defunct copy. I am not sure whether you will also need to reinstall grub to disk but I suspect you will.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#7 2013-10-02 23:56:12

jayflo
Member
Registered: 2013-09-06
Posts: 33

Re: [Solved] Restore system from backup using rsync

I understand that after rsync'ing the backup files (on the external drive) to the fresh install, that I need to update the fstab (since the UUID's changed).  However, if I rsync over the /boot directory, then the backup copy of

/boot/grub/grub.cfg

will now be part of the arch system on my computer.  I have a couple questions:

1) If I rsync'd everything except /boot/grub/grub.cfg, what about the fresh install grub.cfg file needs to be updated?  Does it also have old UUID's within it that need to be updated?
2) Does the command

grub-mkconfig -o /boot/grub/grub.cfg

generate the grub.cfg using /etc/fstab (if at all)?  Or does it load the information (which needs to be updated) from some other (memory) source?  If it is the latter, would I need to restart my computer (after rsync and updating fstab) before generating grub.cfg?  (and...restarting wouldn't work at this point since I have would not have updated the grub.cfg?)

Offline

#8 2013-10-03 00:05:38

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,168

Re: [Solved] Restore system from backup using rsync

grub-mkconfig does not use fstab. The reason it doesn't matter if you rsync /boot entire is that grub-mkconfig will overwrite the old grub.cfg anyway so it is irrelevant whether that gets copied or not.

grub-mkconfig tries to figure stuff out on its own. /etc/default/grub and /etc/grub.d/* may contain customisations which you've configured (or may not).

Since you are doing this from a live media, I assume, I would arch-chroot into the newly restored system and run grub-mkconfig (and probably grub-install) from there.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB