Backup Using Rsync

Performing a Full System Backup, excluding anything already packaged or easily gotten elsewhere. This is usually a tedious task, but the following, tried & true, procedure simplifies this task so it can be done easily at the whim of a few key presses!

Description
I prefer using rsync and mirroring my entire system to an external firewire (not USB) or other hard drive. Reason we prefer firewire, processes bypass the CPU. USB doesn't. Each packet goes through the CPU using more resources than required for this task.

(If, later, you are replacing the drive, you might also want to dd the boot sector. It will save a few steps during restoring.)

Backup
A more readable incantation for scripts with some additional options:

The following exclude file lists some examples of folders you probably do not want included (ie. Any possible mounted media & NFS exports).

The following two files need to be preserved, but rsync doesn't preserve the device nodes, so you'll need to recreate them using mknod which I document within the Restore section below.

Backing-up the boot sector using dd
Backing-up the boot sector is easy to do with the commandline tool dd.

The master boot record (MBR) contains the boot sector and the partition table of the disk. To backup the whole MBR (including the partition table) of, say, '/dev/sda', use:

Restoring
To restore, boot with System Rescue CD and use:

You'll also need to recreate the /dev/console & /dev/null device files on the restored filesystem:

On first boot of the restored system, you may need to recreate some missing system folders, run emerge --sync to recreate /usr/portage, reinstall the kernel on /usr/src/linux, etc, if they were within the exclude list during backup.

To restore the MBR with dd, use:

Note that this will also overwrite the partition table on /dev/sda with the one in the backup. This may not be desirable, particularly if the partition table is altered after the backup has been made. To restore only the boot sector, leaving the partition table as is, use:

Boot Sector (Grub) Restore
You may need to reinstall the boot sector if this is a new hard drive.

To backup or restore the boot sector, either use the commandline tool dd to backup & restore the boot sector. Or, if the boot folder was included with the rsync, just use grub-install. You may need to install it manually using the grub command line. (specifying the grub commands "rootfs and "setup" specifying your drives specifics!  The following is an example only!)