This rsync script allows creating a full backup copy across file-systems. It is setup so that the copy includes intact booting capabilities, optionally excluding selected files.
The approach has benefits over omitting system files by just copying personal data; if the system becomes corrupted in the main partition, overcoming the problem means booting into the backup as opposed to identifying and reinstalling affected programs followed by copying back personal data.
Instructions were converted from this forum post.
File-systems in the backup source and destination device need to be the same type. It could work with a mix of ext3 and ext4, but this hasn't been tested. For booting capabilities, the partitioning on the backup source does not matter, whereas the device the backup will be copied to (destination device) needs to have a single partition.
Two files are needed; the backup script and a file stating which files to include/exclude from the backup source.
The script is very simple; it rsyncs in archive mode, ensuring that symbolic links, devices, attributes, permissions and ownerships, among other file attributes are preserved, while excluding files that match the patterns from the include/exclude list.
- Backup source; Template:Codeline
- In this case it's performing a backup on the whole root.
As deciding which files should populate this list can be difficult, here's a typical backup example that excludes common files that don't need to be backed up, such as the vast majority of Template:Filename. Note that specifying every desired file or directory in Template:Codeline is not needed; this section only acts as a filter for statements in Template:Codeline. This file is in the traditional include/exclude rsync format.
- Content in system directories; Template:Filename, Template:Filename, Template:Filename and Template:Filename are excluded because they are created by the system at runtime. Note that the directories themselves need to be preserved since they are not regenerated at boot.
- Even though Template:Filename is excluded, 4 files that are not dynamically created by udev need to be preserved. These are Template:Filename, Template:Filename, Template:Filename and Template:Filename.
# mount /dev/sdb1 /media/mountpoint
Run the backup script:
# ./rbackup.sh /media/mountpoint/
rsync will then backup to that destination.
After the sync is finished, a boot loader needs to be installed on the backup destination, and configuration in the destination's Template:Filename needs to be amended to reflect the new location.
These instructions assume GRUB is the bootloader of choice.
Open the GRUB console:
Direct the install towards the destination device:
root (hd1,0) setup (hd1)
The Template:Codeline command should point to where the GRUB files are located--in this case, "Template:Codeline" means the second storage device (Template:Filename) and "Template:Codeline" is the first partition (Template:Filename).
The problem here is that even though the boot loader installs correctly, its menu entries are for the main system's partitions, not the backup system's.