System backup to DVD

Splitting Files

The purpose of this article is to detail how to backup a Linux system using a DVD writer; this will likely take multiple DVDs.

Rational

A backup can be done to multiple DVDs in situations where it is necessary. However, keep in mind DVDs can be damaged and that the organic dye in DVDs deteriorates over time… backing up to external hard drives is recommended.

System backup

Start an install CD or other likewise media to be able to access the drive/partition without system operation interference. Backups must be done from an external medium as files are constantly written to on a live system.

mkdir /mnt/distro
mount /dev/sd[#] /mnt/distro
cd    /mnt/distro
tar   -czvf distro_`date +%F`.tar.gz .  # (c)reate (z)ip (v)erbose (f)ile

Backup split

The backup can be split into multiple files so they will fit on a DVD.

Note 1: A DVD’s storage capacity may be smaller then some expect. The reason is because the original computer developers wanted to use binary as the base storage measurement (a kilobyte to be 1024 bits) and erred when they adopted metric prefixes. Data storage manufacturers began using these 1000 base prefixes because they displayed larger values. A 4.7 GB DVD in binary units with the later and gradually being adopted binary prefix is 4.37721 GiB— this is the number that computer veterans typically expect. (GB to GiB conversion fraction: 1,000,000,000/[1024 * 1024 * 1024] = 0.9313226)

Note 2: The UDF file system, typically used for DVD data storage, at the time of this writing was still experimental on Linux and I choose to use the ISO-9660 file system for reliability. However, this file system has a file size limit of four GiB. Since my writable DVDs had a capacity of 4.7 GB I had to split up the files to two per DVD. File system overhead also has to be factored in and I reduced 2.188608100 GiB to 2.188000 GiB.

tar usage

With tar create a Length-defined, Multi-volume archive (length is in 1 KiB units):

tar -cML 2188000 -f distro_`date +%F`.tar.gz_00 distro_`date +%F`.tar.gz

After the first segment is split a prompt will request the name of the next file (Prepare volume #2 for 'distro_DATE.tar.gz_00):

n distro_DATE_tar.gz_01

(This command, tar and multi-voluming, can also be done from the beginning of the backup if archive compression is unnecessary.)

split usage

Splitting can also be done with the split command. Here 2.188000 GiB is converted to 2240.512 MiB and -d adds a numerical suffix:

split -b 2240M -d distro_`date +%F`.tar.gz distro_`date +%F`.tar.gz_

DVD write

To use growisofs to burn the files to a writable DVD disc:

growisofs -Z /dev/dvd -rJ distro_`date +%F`_00.tar.gz distro..._01.tar.gz

System restore

Boot from the Install CD or other boot medium (boot with a caching option if available in the boot menu if another DVD reader is unavailable).

$ umount /dev/dvd && eject
mount /dev/dvd /mnt/dvd
mkdir /mnt/distro

Create the file system on the drive/partition if necessary and mount it.

Backup join

With tar:

tar -xMf distro_`date +%F`.tar.gz_00 distro_`date +%F`.tar.gz

With cat (for the split files):

cat distro_`date +%F`.tar.gz_* > distro_`date +%F`.tar.gz

Backup restore

tar xvf distro_`date +%F`.tar.gz -C /mnt/distro

Resources