Backup to DVD
From Gentoo Linux Wiki
Backing up to DVDs may be your only measure to save important data on your computer. This article describe how to backup your Linux configurations or system and then split the backup onto multiple DVDs.
Contents |
[edit] Manual Backup
The process described here uses tar for either a configuration backup or a complete system backup.
[edit] Partial Backup
Doing a full system backup isn't often required because packages are updated usually very regularly in Linux.
To do a partial backup we'll just concentrate on the personal data and configuration files.
#!/bin/bash # System-configs, /home cd / tar cvpzf backup-partial.tgz /boot /etc /var/lib/portage/world /home \ --exclude=/home/<USER>/.mozilla/firefox/*.default/Cache \ --exclude=/home/<USER>/.Trash \ --exclude=/home/<USER>/.local/share/Trash/files
This will backup the kernel and the grub files, your home directory, the portage world file (has a list of all your install portage packages), and all the configurations in /etc/.
[edit] Full System Backup
Best to do this from an external OS, the Gentoo Minimum CD works nicely, but any install CD will do. It is good to use an external OS because files can change on a used system and because it will not include any temporary filesystems like /sys.
Start the installCD or other OS and in the console/terminal make a directory to mount the system we intend to save.
Mount it:
Now change to that drive/partition,
and compress it:
[edit] Splitting the Backup
It will take a number DVD's to backup the system depending on whats installed.
Because UDF (the DVD file system) write support in Linux is in an alpha stage using ISO-9660 format here is better for dependability.
ISO-9660 has a file size limitation of 4 GiB so the files here will be split into 2 2.2GB segments to fit well onto the DVD. A little overhead on the file size if provided as the ISO filesystem requires some space for it's data (boot information, file system type, etc.).
The archive can be broken up with split or tar.
[edit] Break with Split
gentoo-system-backup.tgz.split. will be the prefix the split files start with, split will automatically append the numbers.
[edit] Break with Tar
-
-c(create) and-M(multi-volume) breaks up the file. -
--tape-lengthrefers to Unix original days when they actually backed up to magnetic tapes on large reels.--tape-lengthis in 1024 bytes measurements (or 1 computer kilo).
After the first segment, at the prompt specify new (n) and the filename for the next segment:
For those curious, DVD's are marketing as 4.7GB but are a metric value not binary. This makes the real (binary) number at 4.38GB of space on a DVD. So calculated right:
- DVD - 4.7 GB (metric) = 4.38 GB (binary) = 4592762 x 1024 kB
[edit] Burning Backup to DVD
Use growisofs to burn the DVD because it has support for RockRidge extensions (unix attributes) - growisofs is part of dvd+rw-tools.
Untested: To burn to a UDF filesystem (the official DVD filesystem - has support and large file sizes):
[edit] Restore Backup
Boot the Gentoo Minimal Install CD, or other LiveCD that supports copying the CD's contents to memory. This is needed for alot of people who don't have an extra DVD/CD drive on their computer. For Gentoo boot the disk and at the option prompt type:
When the command prompt is seen, eject the disk:
[edit] Setting Up the Restore Partition
Mount the partition to restore on:
Format the partition to your preferred filesystem, for example:
Insert the first DVD and mount it:
Copy the file to the restore partition:
[edit] Putting Back Together Again
Putting it back together again is the easy part.
Joining Split Files
Joining Segmented Tar Files
Be sure to use the original filename of the original archive or tar will refuse to rebind them. Again you will have to name the next tar segmented file: