Backup live boot drive

Hi

A have a Ubuntu server - Is there any way for me to back up my boot drive - Without unmounting or rebooting the server?

I’ve tried a few ways, but I always get permission issues (likely because it is mounted?)

Ideally it would be compressed as it is a large drive - Largely empty

For /boot you need to be root I believe? You should be able to mount the boot partition and cd into it…?

timeshift can be GUI or command line. really it is a set of features that just use RSync, but it makes stuff easy so might be worth a look. (fully supported on Ubuntu.)

It would be helpful to know a bit of the drive setup; off the top of my head, the outputs of

  • lsblk
  • df
  • cat /proc/mounts

should help shed some light on how your system is divided among mount points.

Also, are you trying to back up /boot or your whole system root (/)?

I was hoping to create a full drive .img or .iso type file for backup purposes, should the drive fail. Something along these lines that I found online

sudo dd if=/dev/nvme2n1 | sudo gzip > serverBootDrive.img.gz

Revelant info is :

nvme2n1     259:4    0 931.5G  0 disk 
├─nvme2n1p1 259:5    0     1M  0 part 
└─nvme2n1p2 259:6    0 931.5G  0 part /

Filesystem      1K-blocks       Used Available Use% Mounted on
tmpfs            13180744       5304  13175440   1% /run
/dev/nvme2n1p2  960833492   30404048 881575112   4% /

First partition being boot, second ext4

1 Like

I see now what you want to do. Unfortunately, doing this while the device is in use (and potentially being written to) will lead to an inconsistent image that may or may not be functional. This type of backup can only be created offline.

1 Like

Install 2nd drive
Boot clonezilla,
Select source drive, select destination dirve, and select disk to disk copy
When complete the copy will also be bootable.

1 Like

Isn’t the general consensus, to seperate OS from data, then just backup config files of OS, while the data can be frozen for backup/restore?

So… Dont do it live… Need to shut down

When you boot clonezilla live.
( from your optical or usb drive ) you are not running the os on your hard drive.
So essentially it is not being written to at all
It wil be dd copied from the systems hdd to the second or destination drive.
And it includes the boot sector information from the source.
This make the cloned drive bootable as well.

This is all i use.
With a desktop computer equipped with hot swap bays, swapping a drive is as fast as shutdowm, swap tray, and reboot.
Even with a slow machine your only looking at 3 to 5 minutes downtime.

If youve never used clonezilla i highly suggest going to their site and take the time to read it carefully.
There are many ways to clone a drive, but for most general purposes you should select disk to disk clone.

You can also do just partition cloning by various methods as well.

And with the net clone option ( machine to machine( or multiple simultanious machine to machine) you can really go big
However a word of caution on this method.
Net cloning must not be connected to the internet or any machine you dont want erased.

Perhaps, switching to a snappshotting FS, would allow live replication?

You can use whatever method you wish.
Most live backup solutions short of direct copying only copy data and can be recovered by restoration.
But reading data formats without the proper software just results in errors.

The problem that generally arises is that people rarely log document backups specifically.
Important data is backed up frequently depending on the amount of work that was done.
Or when installing new software.
Windows repair dates allowed you to recover your system to set save points. You could choose from to undo a problem following an update or install.
This took over the intrinsic need for backups.
But did not address the loss of work.
Backing up prior to a system software change allowed up to date data files.
In the event of a fatal system crash, your os could be restored, drive could be replaced, os installed, and data restored from the backup with very little data loss.
Archiving files is an art form if done properly!
Transcribing information from older media to newer keeps the data in up to date media.
This serves a purpose for research reasons

Logging the backups was not difficult but many regard logging or even backing up data as a pain in the arse.
Keeping a log book is simple. Date, reason, comment, machine, and initials
And the log book can be anything from a notebook, to an actual log book.
( note here (Not a file on a computer, failure of that drive or corruption of that file and your index is lost))

In the past 25 years most people have virtually forgotten the importance of backups because of the ever increasing size of storage media.
And then piss and moan when they lose gigabytes or terabytes of data when the drives take a s#!t

Yeah im showing my age here🤣
Im an old fart!

I tend to be a bit surley because when my customers blame their machines for losing their data from crashes. ( they expect me to rescue them from their own preventable screw ups)
And get obnoxious when you cant recover a dead drive.

Surely they never understood the importance?

But, larger storage reduced pruning/ effective choice in what to keep, whee before, the limit meant one had to prune, and also backed up what was left, now pruning less needed, backup not considered either?

Ive gotta admit though, first time using clonezilla can be very daunting because there are so many choices.
But under guidance in proper choice and method, its dead simple after the first couple times.

We used to clone drives at work with a kangaroo hardware disk cloner ( gawd that thing was slow)
And it took about 6 hours to clone a 40 gig drive.
Clonezilla did it in 10 minutes ( this was about 15 years ago)
Aside from the hash file number the copies were identical

Provided that only one of the two are present at boot. Otherwise, as you have cloned the UUIDs confusion (user and computer) sets in.

I have a ZFS pool on this server

That is backed up, externally

What is the consensus on moving my boot/os drive over ? (I think I’ve read the root can be moved over - Presumably not the boot partition?)

Does this cause more problems than it solves?

In the term as a boot drive yes both are able to boot. But your system will boot from the default or higher level in the boot order.
Cloning a boot drive gives you a redundant os drive. In the event your original fails, its just a simple swap out without the hassle of re installing everything.

Non os storage can be cloned as well.

The only issue you may run afoul on is hotswap of the old scsi hdd’s in a raid ( damn im showing my age now):disappointed:

But then when the system boots, if the boot loader is grub it looks for the OS by UUID, and when the OS boots by default it mounts volumes by UUID. If the UUIDs are not unique, you might get either. I mentioned it because I did it, and the booted OS was not from the drive I’d chosen in the boot order.

Generally the drive you are cloning is not left in the machine but reserved as a safety copy.
Disk to disk cloning is making an exact copy including the boot sectors.
However partition to partition cloning make exact copies of source partition onto the destination disk.
Clonezilla is powerful! Of that there no doubt.
Many of its functions can be done in terminal but clonzilla is far easier.

Gparted is another power tool.
I used to use dban to wipe drives but it doesnt work very well on sata/ pata drives.
While it does blank them it will close with errors.
So run gparted repartion the drive.
Shut down, reboot gparted, delete the partitions and repartition it again.
Any old data is unrecoverable.