1

I have two drives setup as follows: First HDD

Second SSD

My goal is to boot into a Linux 22.04 install on the first drive pictured located on partition labelled "Admin-1", and use the "Disks" utility to create a clone of the partition labelled "WebDev-1" on the second drive pictured (which contains another installation of Linux 22.04). I want to save this .img file on the partition labelled "WebDev-1-Backup" which you can see in the first image. Both partitions are the exact same number of bytes.

Unfortunately, when I've tried to do this using disks and "create partition image" I get an error message that looks like this:

enter image description here

I use the "WebDev-1" partition as an os to boot into to try and do some web development stuff, the problem is in the process of installing various things its common to brick the install, which is why I want to use the "Admin-1" Ubuntu image to periodically create clones of it for backup and restoration when things go wrong.

Not sure why I'm getting this error message, or if there is another slightly different way of doing this. The goal is basically just to have "WebDev-1-Backup" partition be an exact copy of the "WebDev-1" partition that I can overwrite and replace as needed.

I was able to accomplish something very similar in the past, and I thought I was only using the Disks utility to do it, but I may be misremembering. Any tips appreciated.

  • 1
    When using Disks to clone a partition you need to boot from a Live USB I think. See also: https://askubuntu.com/questions/1300540/how-to-duplicate-a-ubuntu-system-for-distribution. – C.S.Cameron Nov 21 '22 at 04:00
  • Gonna try this when i get home and see if it solves my issue. But i think you may be right on with this. I vaguely remember maybe that is what i ended up having to do last time also. Just wish there was a way to do it from a system on a real drive as the live usb thing takes a lot of time to load. – larakikato Nov 21 '22 at 17:03
  • So I tried doing it by running on a live usb, and unfortunately that also did not work, and resulted in the same error. I also tried selecting to save the image in a partition with much more free space (151gb, which should be well more than enough), and I still got the same error. – larakikato Nov 21 '22 at 23:42

1 Answers1

0

I wasn't able to figure out how to do this using disks, but I found that I was able to accomplish the goal by using a couple of terminal commands instead:

To backup: sudo sh -c "dd if=/dev/sdb3 status=progress | xz -c > /media/laraki/WebDev-1-Backup.img.xz"

(replace /dev/sdb3 with whatever partition you want to backup, and /media/laraki/WebDev-1-Backup with the location and name of your desired backup file)

To restore from backup: sudo sh -c "xz -d -c /media/laraki/WebDev-1-Backup.img.xz | dd of=/dev/sdb3 status=progress"

(Here again just replace with your location of backup file and the partition you want to restore. )

In my case these worked and allow me to login to my "admin" os to create and restore from backup points.

Don't use these commands on a partition which is currently in use as apparently it could lead to corrupted data.

  • You’ve solved the question you asked - but I do question the approach of using dd to clone your entire os partition as a good backup strategy. dd of the whole partition will write a lot to your ssd / hdd (literally every bit of data), which takes time and causes unnecessary wear. Consider all the data you haven’t customised - that doesn’t need to be copied for a good backup. I’d consider if you can come up with a good backup method that doesn’t copy so much unnecessary data - eg using rsync. – Will Nov 29 '22 at 14:48
  • Hmm it is a solution unlikely to garner a lot of praise. It is far to heavy-handed and resource intensive to consider for routine backups in any production environment. You should look into snapshot capable file systems. – Frobozz Dec 03 '22 at 20:02