The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Rsync Backup"
(correct name) |
(No difference)
|
Revision as of 08:52, October 29, 2014
Introduction
This tutorial leads you through the process of backing up and restoring your OS. This process is completed using the rsync
tool that is included in SystemRescueCd.
Why SystemRescueCd?
The usage of SystemRescueCD is quite simple: it enables us to backup the contents of our entire OS.
Backing Up
Preparation
By default, SystemRescueCd provides a /mnt/backup mount point. We will use this. There is no mount point for Funtoo. We have to create one:
root # install -d /mnt/funtoo
When you use SystemRescueCd to backup you OS for the first time, you also have to create mount points for additional partitions. In this tutorial we assume that there is a /boot and a /home partition. Create the directories in /mnt/funtoo:
root # install -d /mnt/funtoo/boot root # install -d /mnt/funtoo/home
We also assume that we are backing up a sytem to an external drive. Plug in the USB device and power it on.
root # cat /proc/partitions major minor #blocks name 8 0 488386584 sda 8 1 512000 sda1 8 2 32768 sda2 8 3 2097152 sda3 8 4 52428800 sda4 8 5 433314823 sda5 8 16 488386584 sdb 11 0 1048575 sr0 8 48 488386584 sdd 8 49 229032928 sdd1 8 52 1 sdd4 8 53 259352576 sdd5
The above command helps you to determine the device name. Lets's suppose that your backup device is /dev/sdd1. Mount the device now - along with your Funtoo partitions.
root # mount /dev/sdd1 /mnt/backup root # mount /dev/sda4 /mnt/funtoo root # mount /dev/sda5 /mnt/funtoo/home root # mount /dev/sda1 /mnt/funtoo/boot
Backup
Now, we backup our Funtoo partition:
root # rsync -aHA --del --force --stats --progress /mnt/funtoo /mnt/backup
Snapshot
Once this command has completed, you can create a snapshot. Create a snapshot folder if there is none:
root # install -d /mnt/backup/snapshot
Give your snapshot copy a name that includes the date. Therefore, you may keep as many snapshot copies as you want and use one of those copies to restore your system to its state at any given date:
root # cp -al /mnt/backup/funtoo /mnt/backup/snaphot/snap-2K014B26-a
In our example, the name of the snapshot tells us that it was created on February 26th (B26) 2014 and it is the first one (a) made on that date.
Log of backups
Logging backups is not mandatory but can be useful. Create a log file and add a descriptive, yet short record for each of your backup. Here is an example:
Date File Description ----------------- -------------------- ---------------------------------------------------------- Feb 26th 2014 snap-2K014B26-a Backup after system update : - New kernel installed
Restoring
First, you have to boot your PC with SystemRescueCd. Next, create and format partitions as per installation guide. For the sake of brevity, we assume that we are restoring the /boot, / and /home partitions. First, you must create a mount point for Funtoo:
root # install -d /mnt/funtoo
Mount partitions
root # mount /dev/sdd1 /mnt/backup root # mount /dev/sda4 /mnt/funtoo root # mount /dev/sda5 /mnt/home root # mount /dev/sda1 /mntboot
If /home and /boot fail to mount, simply create the appropriate mount points and run the mount commands again.
Restoring from latest backup
root # rsync -aHA --del --force --stats --progress /mnt/backup/funtoo/ /mnt/funtoo
The / at the end of /mnt/backup/funtoo/
is mandatory -- not a typo.
Restoring from a previous backup
root # rsync -aHA --del --force --stats --progress /mnt/backup/snapshot/snap-2K014B26-a/ /mnt/funtoo
The / at the end of /mnt/backup/snapshot/snap-2K014B26-a/
is mandatory -- not a typo.
Restoring GRUB2
Once the system has been restored, GRUB2 must be reinstalled. The example below is for a GRUB/Bios partition schema. This assumes that the Funtoo partitions were created on /dev/sda:
root # cd /mnt/funtoo root # mount -t proc none proc root # mount -o bind /dev dev root # mount -o bind /sys sys root # swapon /dev/sda3 root # cp /etc/resolv.conf etc root # env -i HOME=/root TERM=$TERM chroot . bash -l root # grub-install /dev/sda
If, for some reason, the partitions were not created on the same devices -- (let's say they were moved from /dev/sda to /dev/sdb) -- please amend /etc/boot.conf
and /etc/fstab
accordingly before running boot-update
.
root # boot-update
You're done. Unmount partitions and reboot.
Credit
This is an as-is translation by Guy Fontaine (AKA Aramis_qc) of an original French tutorial written by Sylvain Alain (AKA d2_racing). Some parts were reviewed and modified to reflect Funtoo GNU/Linux instead of Gentoo GNU/Linux.