
Clonezilla Automated Backups

Clonezilla Backup Automation
References: Official Clonezilla.org Preseeding “Guide”
List and Examples of Boot Parameters
Stack Overflow Question and Answer
Requirements: Clonezilla live bootable image on USB
Authentication credentials for Drobo NAS device
Edited syslinux.cfg file with desired backup parameters
Summary: Parameters must be modified in the syslinux.cfg file to bypass selecting backup options. This is contrary to what I thought originally which was the grub.cfg file. The difference is in the boot method; syslinux is used for USB flash drives while grub is used only for uEFI boot loaders.
It is extremely important to note the version of Clonezilla you’re using as nomenclature has changed a bit over releases and the official documentation and examples do not always reflect this. (Example: choose vs user_choice)
This guide is based on using live version 2.7.3-19-amd64.
The straightforward modified file preseeds are for the locale (en_US.UTF-8) and keyboard layout options (en) which follow the ocs_prerun scripts.
The following were taken from the developer notes and based on using a SAMBA server like the Drobo unit I used for this case.
Script Additions for Automated Backups
ocs_prerun1="dhclient -v eth1"
Explanation: dhclient determines IP and network adapter to be used by the client. For my test sample, this is eth1 WAN port of the mini PC labeled with IP 192.168.26.xxx
ocs_prerun2="sleep 2"
Explanation: None provided that I could find or at least a specific explanation for Clonezilla’s requisite time delay. Sleep just makes a delay between other scripts which even a delay of 2 seconds as in this case is necessary to keep the program from hanging up and crashing.
ocs_prerun3="mount -t cifs -o user=randy,password=password //172.29.25.230/images /home/partimag"
Explanation: This is the sourcing step for the target location. This mounts the Drobo as the storage location using cifs command (common internet file system.) The next section provides authentication to the Drobo using our credentials. Obviously use your username and actual password for this. The destination is defined by IP and target directory. The last section /home/partimag is the default source format Clonezilla expects and has already been pointed to the Drobo.
ocs_prerun4="sleep 2"
Explanation: Another necessary delay between scripts to prevent program crashing.
ocs_live_run="/usr/sbin/ocs-sr -q2 -c -j2 -z1p -i 4096 -sfsck -senc -p choose savedisk AutoTest2 sda"
Explanation: This is the execution to start the actual backup. Every option can be configured using combinations of flags to make the desired choices including advanced options such as the partition resize like we used for upgrading the conference machine’s hard drive. Obviously, there are many possibilities, but I have chosen the ones I think we’ll use most commonly for backups.
By breakdown:
-q2 | --use-partclone (Uses partclone app to save image as partitions.) |
-c | Wait for confirmation before saving or restoring. |
-j2 | --clone-hidden-data (Uses dd to clone between MBR and 1st partition.) |
-z1p | Compress using parallel gzip program for multi-cpu machines. |
-i 4096 | Sets split image file volume size in MB. Default is 4096. |
-sfsck | Skip running file check on source file system before saving it. |
-senc | Skip encryption. |
-p choose | Postaction flag. Choose either poweroff, reboot, or command prompt. |
savedisk | Saves image of entire disk. |
AutoTest2 | Name of backup. |
sda | The drive to be cloned. |
Example:
Sample full script:
label Clonezilla live (To RAM)
# MENU DEFAULT
# MENU HIDE
MENU LABEL Clonezilla live (VGA 800x600 & To ^RAM)
# MENU PASSWD
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 ocs_prerun1="dhclient -v eth1" ocs_prerun2="sleep 2" ocs_prerun3="mount -t cifs -o user=randy,password=password //172.29.25.230/images /home/partimag" ocs_prerun4="sleep 2" noeject locales=en_US.UTF-8 keyboard-layouts=en ocs_live_run="/usr/sbin/ocs-sr -q2 -c -j2 -z1p -i 4096 -sfsck -senc -p choose savedisk AutoTest2 sda" ocs_live_extra_param="" ocs_live_batch="yes" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0 nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
TEXT HELP
All the programs will be copied to RAM, so you can
remove boot media (CD or USB flash drive) later
ENDTEXT
Total User Inputs Required 4: initial boot override, Clonezilla main menu option, action confirmation, and power off/reboot/command line selection.
Notes: Since we’re automating, all backups will share the same name by default. This can easily be changed after it’s done but needs remembered if we run a second backup after a first.
Due to customizing settings we should probably designate one Clonezilla USB for backups and one for restorations.
WARNING: As scripts execute, Drobo password is displayed in plain text for approximately 40 seconds.
Menu Customizations
Change Summary of syslinux.cfg (from beginning to end of file) for menu customizations:
- Line 9 MENU BACKGROUND ocswp.png → logo.png
- Line 29 MENU TITLE clonezilla.org, clonezilla.nchc.org.tw → Bilmar Lab System Backup
- Line 35 MENU LABEL Clonezilla live (VGA 800x600) → Default Mode: Clonezilla live to RAM
- *Lines 33-43 and 45-55 full swap of Clonezilla live (VGA 800x600) and Clonezilla live (VGA 800x600 & to RAM) sections to change default option
- Line 60 uncomment out MENU hide to hide option (Clonezilla live HiDPI)
- Line 72 uncomment out MENU HIDE to hide option (Clonezilla live speech synthesis
- Line 86 uncomment out MENU HIDE to hide option (Other modes of Clonezilla live)
- Line 141 uncomment out MENU HIDE to hide option (Clonezilla safe graphic settings)
- Line 152 uncomment out MENU HIDE to hide option (Clonezilla live failsafe mode)
- Line 165 uncomment out MENU HIDE to hide option (local operating system in hard drive)
- Lines 186-223 delete MENU BEGIN sections for Memtest and FreeDOS options