You are not logged in.

#1 2020-01-14 12:34:53

Valctar
Member
Registered: 2017-03-30
Posts: 10

[SOLVED] System backup/clone

I'm trying to make a bootable system clone to another partition on the same computer. I did an rsync -a from / to the other partition. This method works on mac for me, however my bootloader can't seem to recognize my clone, (bootloader code is just as the wiki recommends)

- how do you guys clone/backup the system? bonus points for cli tools
- is there some specific thing that needs to be made to a linux fs to make it bootable? I'd love to learn that.

thanks for any help smile

Last edited by Valctar (2020-01-30 15:52:04)

Offline

#2 2020-01-14 15:09:26

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] System backup/clone

There is a huge difference between backing up and disk cloning.
Using rsync you would need to setup a system first then copy the relevant parts to it..
If you really think need an image / clone use the tools that can do that.
Read the wiki on backing up / disk cloning thoroughly, you have missed some relevant information.

Offline

#3 2020-01-14 15:16:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,517
Website

Re: [SOLVED] System backup/clone

Is your current system all on a single partition?  If so, rsync should work fine.  I disagree with the above - there'd be no need to set up another system first if you are really syncing over everything.

However, booting the backup is a different story.  What you need to do to make the new system bootable depends entirely on your bootloader/bootmanager which you've told us nothing about.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#4 2020-01-14 15:22:22

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,494

Re: [SOLVED] System backup/clone

Yes, you're right, I never thought about a single partition, never use that way to setup a system..

Offline

#5 2020-01-14 20:22:38

NuSkool
Member
Registered: 2015-03-23
Posts: 141

Re: [SOLVED] System backup/clone

I'd like to add that it's also possible to do a full system backup up from multiple partitions with rsync, and have the backup be bootable. I do it weekly.

Can provide links to script if requested.

Offline

#6 2020-01-15 01:12:16

Valctar
Member
Registered: 2017-03-30
Posts: 10

Re: [SOLVED] System backup/clone

NuSkool wrote:

I'd like to add that it's also possible to do a full system backup up from multiple partitions with rsync, and have the backup be bootable. I do it weekly.

Can provide links to script if requested.

I'd love to take a look at that.

For bootloader I'm using clover https://wiki.archlinux.org/index.php/Clover.

Offline

#7 2020-01-15 05:08:02

NuSkool
Member
Registered: 2015-03-23
Posts: 141

Re: [SOLVED] System backup/clone

OK, here's what I'm using.    http://codepad.org/4oeq8b1e   My guess is someone a lot smarter than me could reduce this script by half though.

Note how to do multiple partitions, and take note use of the more or less required '--delete' option. This keeps pacman databases straight (I actually installed packages / updated from within backup as testing, lol) and keeps the backup from growing in size beyond the system being backed up. I use an old removable HDD bay with an equally old Hitachi HDD for backups. The UUID stuff prevents me from accidentally backing up onto something not intended when the removable drive is shut off. (looking into a serial port controlled SSR for automated switching)

I use grub, and just added an entry for backup, and edited /etc/fstab if I recall correctly. Hopefully not leaving anything out. I do occasionally boot into it. It's set up for weekly backups via cron. Probably a systemd timer would be more commonly used these days.

EDIT:
Use the  '--dry-run' option when testing rsync.
Also note '<removed obscured>' should be the UUID of the intended destination partitions.

Last edited by NuSkool (2020-01-15 05:43:03)

Offline

#8 2020-01-15 05:50:45

dakota
Member
Registered: 2016-05-20
Posts: 278

Re: [SOLVED] System backup/clone

I don't know if this will work for you or not, but this is what I do.

I have a hard drive with 5 partitions:

/dev/sda1 - /
/dev/sda2 - /home
/dev/sda3 - swap
/dev/sda4 - clone of /
/dev/sda5 - clone of /home

Partitions sda1 and sda2 are mounted during startup. (Partitions sda4 and sda5 are commented out in fstab.)

I update my system weekly via pacman. But before I do that I logon as root, mount

/dev/sda4 => /mnt/mirror
/dev/sda5 => /mnt/mirror/home

and then rsync sda1 => sda4, sda2 => sda5.

When that is complete, I edit /mnt/mirror/etc/fstab to comment out sda1 and sda2, and uncomment sda4 and sda5.

Then I reboot, change the command line parameter from root=/dev/sda1 to /root/dev/sda4, and boot into the cloned system. When I verify that I can do that, I reboot back into /dev/sda1 and update my primary system via pacman.

If I really mess up my system (during an upgrade, or just plain messing about), I can boot back into a known, good configuration.

$ cat /etc/fstab
----------------
## <file system> <dir> <type> <options> <dump> <pass>
## /dev/sda1
UUID=c7c442f2-90d8-4e6a-a735-65cb052f90f5       /               ext4            rw,relatime,data=ordered        0 1

## /dev/sda2
UUID=981eef61-efaa-4e1d-9775-13260481797f       /home           ext4            rw,relatime,data=ordered        0 2

## /dev/sda3
UUID=a389724a-e8f3-4c01-8355-3b141a097ef7       none            swap            defaults                        0 0

## /dev/sda4
# UUID=a23e01c0-2f3f-4db4-81e1-2815f7439b14    /                ext4            rw,relatime,data=ordered        0 1

## /dev/sda5
# UUID=2d1891c1-45eb-4b08-b679-2777e12d7d6f    /home            ext4            rw,relatime,data=ordered        0 2
$ cat /root/backup_mirrorDrive.sh
----------------------------------
rsync -aAXHz --progress --delete --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /mnt/mirror/

Edit: I am using Syslinux on bios, created with the syslinux-install_update script.

Last edited by dakota (2020-01-15 06:04:08)


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

#9 2020-01-15 06:12:18

NuSkool
Member
Registered: 2015-03-23
Posts: 141

Re: [SOLVED] System backup/clone

dakota wrote:

When that is complete, I edit /mnt/mirror/etc/fstab to comment out sda1 and sda2, and uncomment sda4 and sda5.

Then I reboot, change the command line parameter from root=/dev/sda1 to /root/dev/sda4, and boot into the cloned system.

You can eliminate these steps.  Add /etc/fstab to your exclude list, and edit /etc/fstab in backup, then just add an additional entry in your boot loader config for your backup.

Last edited by NuSkool (2020-01-15 06:12:57)

Offline

#10 2020-01-16 12:44:02

Valctar
Member
Registered: 2017-03-30
Posts: 10

Re: [SOLVED] System backup/clone

Hey yall, thanks for all your help big_smile I happily booted the clone after I fixed an error in the bootloader configuration file, pointing to the wrong EFI partition.

Offline

#11 2020-01-17 18:38:40

dakota
Member
Registered: 2016-05-20
Posts: 278

Re: [SOLVED] System backup/clone

NuSkool wrote:
dakota wrote:

When that is complete, I edit /mnt/mirror/etc/fstab to comment out sda1 and sda2, and uncomment sda4 and sda5.

Then I reboot, change the command line parameter from root=/dev/sda1 to /root/dev/sda4, and boot into the cloned system.

You can eliminate these steps.  Add /etc/fstab to your exclude list, and edit /etc/fstab in backup, then just add an additional entry in your boot loader config for your backup.

Thanks! That's very cool. I tried this and it worked like a charm. It occurred to me that I could also make the mounting and unmounting part of the backup script also.

Cheers,


"Before Enlightenment chop wood, carry water. After Enlightenment chop wood, carry water." -- Zen proverb

Offline

Board footer

Powered by FluxBB