Jump to content

Backup method for system installed on SSD (slot1)


0utc45t

Recommended Posts

Hi, 

 

I would like to make backup(s) of my system. The system (debian) is installed on sata SSD @ slot 1. I would like to have the backup of the system written to zfs pool on the other slots as an image. Which in case of system SSD failure, I could write back to a new SSD installed on the same slot 1, by booting to a rescue system from micro sd card.

 

Have this kind of functionality already been implemented? Or parts of it? Linux has a bunch of backup solutions, but I suspect they might not work with the helios64 box (sd card, internal ssd). And my only helios64 box is in "production" use, so "trial and error" method is not the first option in my mind...

Link to comment
Share on other sites

Any normal backup solution should work. In general, it sounds like you want to just make an image of the live system. The dd utility will work for this.

 

dd if=/dev/disk/by-id/[your disk] of=/path/to/zfs/pool/root.img bs=1M status=progress

 

You can adjust the block size based on what you find works well for your system. You can later restore it using exactly the same process, just switching your in-file (if) and out-file (of). Note that file here can include block devices.

Link to comment
Share on other sites

In case of disk failure... just copying the filesystem to a backup, which then is copied to a new disk, which is inserted to slot A and booted. It will not boot. I presume so, by the fact that I tried to repartition/resize that disk holding system in slot A and it failed to boot after that. So, there is something more involved, hints are visible by looking at mounts. I would like to get the system backupped. Know the needed bits and tweaks, so that I know that I can do it and it will work, in case of disk failure.

Link to comment
Share on other sites

On 3/4/2021 at 2:43 AM, wurmfood said:

Any normal backup solution should work. In general, it sounds like you want to just make an image of the live system. The dd utility will work for this.

 


dd if=/dev/disk/by-id/[your disk] of=/path/to/zfs/pool/root.img bs=1M status=progress

 

You can adjust the block size based on what you find works well for your system. You can later restore it using exactly the same process, just switching your in-file (if) and out-file (of). Note that file here can include block devices.

Is this something ddrescue can do that is quite similar and sufficient to backup the system? 

Link to comment
Share on other sites

I am using the following script to backup my root partition to sd (it is just a slightly modified Armbian script - please adapt the device name if necessary):

 

# cat backuptosd.sh
#!/bin/bash

# Check if user is root
if [ $(id -u) != "0" ]; then
    echo "Error: You must be root to run this script."
    exit 1
fi

cat > install-exclude <<EOF
/dev/*
/proc/*
/sys/*
/media/data1/*
/media/data2/*
/media/data3/*
/media/data4/*
/media/data5/*
/mnt/sd/*
/mnt/ssd/*
/mnt/usb/*
/mnt/hd/*
/run/*
# /tmp/*
# /root/*
EOF


exec 2>/dev/null
umount /mnt/sd
exec 2>&1

mount /dev/mmcblk1p1 /mnt/sd
rsync -avxSE --delete --exclude-from="install-exclude"  /  /mnt/sd

# change fstab
sed -e 's/UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx3c/UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx2d/g' -i /mnt/sd/etc/fstab
sed -e 's/UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx3c/UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx2d/g' -i /mnt/sd/boot/armbianEnv.txt
umount /mnt/sd
rm install-exclude

 

The UUIDs need to be inserted (blkid is your friend) - the leftmost is the one of your root system, the other one is the UUID of the sd in this example.

If you need a bootable system on sd - the easiest way would be to start with a fresh Armbian image flashed to the sd card and to boot from it at least once in order to expand the filesystem.

Then you may boot from your main root partition and simply sync it to the sd card using the above script.

 

Link to comment
Share on other sites

16 hours ago, 0utc45t said:

In case of disk failure... just copying the filesystem to a backup, which then is copied to a new disk, which is inserted to slot A and booted. It will not boot. I presume so, by the fact that I tried to repartition/resize that disk holding system in slot A and it failed to boot after that. So, there is something more involved, hints are visible by looking at mounts. I would like to get the system backupped. Know the needed bits and tweaks, so that I know that I can do it and it will work, in case of disk failure.

The problem with copying the file system is the UUIDs of the devices are wrong. This is why dd will actually work (and yes, so will ddrescue) because it copies the disk block by block. That means the new partitions have the same UUID. I know this works because I just did it on my main computer. :)

 

The backup script above basically copies the file system and then adjusts /etc/fstab to have the correct UUIDs, so it should work.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines