Some time ago I wrote a simple automation script for taking LVM snapshots, backing them up as disk images, and efficiently compressing in the process. Logical Volume Manager is often overlooked solution in this regard, providing much needed flexibility as a bitwise backup strategy. Key word here being bitwise - exact bit by bit replica. This is exclusively how I backup my systems nowadays. It’s so much smoother than offline disk cloning (Clonezilla etc.), and does not rely on the file system and its structure, as is the case with rsync.

script_running

Main goals of this script:

  • Provides better alternative than using disk cloning tools (e.g. Clonezilla) as a bitwise backup strategy
  • Creates full image of a disk partition using LVM snapshot and dd
  • Doesn’t interfere with nor interrupt normal operation of the system and can be run in the background, thanks to the nature of LVM
  • Backups are compressed with pigz, utilizing multiple CPU cores
  • Backups are encrypted
  • Can be scheduled to run unattended using cron etc.

I store this script, together with detailed documentation, on my github.