The purpose of this repo is to build a fully automated backup solution using Clonezilla engine.
The solution provides the ability to create backups of one/multiple partitions or one/multiple drives of a computer system in a completely unattended mode.
The system boots, determines what should be backed, where the backup should stored, then performs the backup and powers the equipment down.
The solution is based on the bootable clonezilla media.
The only user intervention is to boot the target computer into Clonezilla bootable media. The automatic process take over from there.
-
Boot into Clonezilla
-
Automatically start Custom backup option
-
Inspect local partitions looking for
backup.confconfiguration file in the root folder -
Compare hardware ID of the target hardware to the hardware ID in the
backup.conf(correct backup configuration check) -
Determine backup target partition (backup folder is created in the root folder on that partition)
-
Determine partitions or drives to be backed up
-
Execute the backup
-
Powerdown or reboot the target computer
The resulting backup is created in a folder (folder name is supplied in the backup.conf file) on the backup partition (partition is supplied in the backup.conf file). Backup parameters are also supplied in the backup.conf file. Those are passed to Clonezilla engine at runtime.
In order to have a self-sufficient backup system, I opted to have a 2TB external USB HDD split into two partitions:
-
Bootable Clonezilla partition with Clonezilla application and backup scripts
-
Data partition - where the resulting backup is stored
-
2TB USB hard drive example is this: Seagate Backup Plus Slim 2TB External Hard Drive Portable HDD
-
USB/USBC cable
-
A computer (this repo relies on you knowing Linux command line)
Partition hard drive into 2 separate partitions:
- FAT32 Clonezilla Partition - 512MB
- exFAT Data Partition - 1.8T
Relevant fdisk output for this disk is:
fdisk -l /dev/sdc
Disk /dev/sdc: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model:
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xcb37c45a
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 2048 1050623 1048576 512M b W95 FAT32
/dev/sdc2 1050624 3907028991 3905978368 1.8T 7 HPFS/NTFS/exFAT
- Follow this setup guide to install Clonezilla on the first partition: setup guide
- Copy
custom-ocsfile from the/clonezilla/live/folder to the/livefolder on Clonezilla partition - Navigate to the
/bootfolder on the Clonezilla partition - Backup
grub.cfgfiles (e.g.grub.cfg.bak) in case you make a mistake - Edit the
grub.cfgfile making the following changes:
-
Set timeout to 5 seconds (default is 30):
set timeout = "5" -
Location this line (usually the first Clonezilla menu item):
menuentry --hotkey=r "Clonezilla live (VGA 800x600 & To RAM)" --id live-toram { -
Copy the entire
menuentryblock ahead of the first menublock - the default menu item is 0 (first on the list)menuentry --hotkey=r "Clonezilla live (VGA 800x600 & To RAM)" --id live-toram { search --set -f /live/vmlinuz $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=noble config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales= keyboard-layouts= ocs_live_run="ocs-live-general" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 $initrd_cmd /live/initrd.img } -
In the new block, modify the menuitem description and the boot command according to the following:
menuentry --hotkey=r "Clonezilla Autobackup (VGA 800x600 & To RAM)" --id live-autobackup { search --set -f /live/vmlinuz $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=noble config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales=locales=en_EN.UTF-8 keyboard-layouts=NONE ocs_live_run="/lib/live/mount/medium/live/custom-ocs" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1 $initrd_cmd /live/initrd.img } -
Save
grub.cfgfile
The autobackup setup of Clonezilla is now complete.
Backup configuration file tells automatic Clonezilla what kind of backup needs to be performed. It should be localed in the root folder on one of the drives of the target computer:
/backup.conf
A sample backup file is below:
4c4c4544-0054-3610-804a-c7c04f444b33
7B0DFCE74B228860
-q2 -j2 -nogui -z1p -i 2000000 -p poweroff savedisk xps15dev_system
D2DE19FADE19D815
Let's review it line by line
00020003-0004-0005-0006-000700080009
This ID could be looked up with this command: sudo lshw -quiet -class system | grep configuration | grep uuid
$ sudo lshw -quiet -class system | grep configuration | grep uuid
configuration: boot=normal chassis=desktop family=Default string sku=Default string uuid=00020003-0004-0005-0006-000700080009
The easiest way to build backup.conf file is to boot into interactive Clonezilla, drop into shell instead of starting the backup and look it up there.
Clonezilla checks if correct configuration file has been found and ignores the ones with unmatched hardware IDs
7B0DFCE74B228860
If the target computer has mulitple disk drives, you can specify on of the partitions on the drives that are not part of the backup.
Typically this is the partition UUID of the DATA partition of the 2TB backup drive we are building.
Note that 7B0DFCE74B228860 is UUID of an exFAT partition (windows). Linux ext4 partition UUID will look like 38d9e8cd-deda-4735-ad97-a795665e77fe
You can look up partition UUIDs using sudo blkid command.
-q2 -j2 -nogui -z1p -i 2000000 -p poweroff savedisk xps15dev_system
One by one:
-q2is to use partclone to save partition(s) (i.e. partclone > partimage > dd).-j2is to use dd to clone the image of the data between MBR (1st sector, i.e. 512 bytes) and 1st partition, which might be useful for some recovery tool.-noguiis to disable fancy graphical progress reporting and stick to simple text only output-z1pis compression method using parallel gzip program (pigz) when saving: fast and small image file, good for multi-core or multi-CPU machines.-i 2000000is to set the size in MB to split the partition image file into multiple volumes files.-p poweroffis to shutdown the target computer after backup.savediskis command to backup the entire drive (savepartssaves individual partitions).xps15dev_systemis the name of the target folder for the backup.
The esiest way to build this line is to run an interactive Clonezilla session, select all desired parameters and save the resulting command line. There is also a command line reference here: Man page of ocs-sr
D2DE19FADE19D815
Lines 4 onward list UUID of partitions being backed up.
If you are using savedisk command - any partion on a disk will make Clonezilla backup the entire disk.
If you are using saveparts - you need to specify each partition separately