System backup with mondo restore

Written by Robert -

It's always a good idea to have a systembackup. Normal backups are fine, but being able to recover an entire system is very useful.

For this situation I'm going to use mondo rescue, to provide me with a recoverable system. The advantage of this software is that it creates a bootable iso file that you can use to restore the system with. This can be burned on CD's, DVD's or just regular USB drives.

Installation

In this case I'm using this on CentOS 6. I need to add the right sources for it to work.

cd /etc/yum.repos.d/  
wget ftp://ftp.mondorescue.org/rhel/6/x86_64/mondorescue.repo  


Now let's update yum:

yum check-update

After this, we should be able to install mondo from the repository:

yum --nogpg install mondo

The reason we use the nogpg option, is because there is a small mistake in the repo where it shows the wrong key.

1

Adding a place where it can place the backups

I prefer to use sshfs for this purpose, since the storage I'm going to put the backups on has proper ssh support. To enable it on CentOS6, we need to enable fuse:

modprobe fuse

Before we can install sshfs, we need to enable the epel-release:

yum install epel-release

After that, we can install sshfs:

yum install sshfs

Now that's installed, we can create a directory where we can mount the sshfs share on:

mkdir /mnt/backup

Let's mount the share. In my case, the IP I'm putting the backups on is 10.10.205.134 and the user is root (it's just a local test). The directory on the computer that makes the backup is /mnt/backup and the device with the storage has the disk where I wish to place the backup on, mounted to /mnt/sda:

sshfs root@10.10.205.134:/mnt/backup /mnt/sda

Now the folder is mounted, you can verify that you can make and remove files on the share. If that all works, we can create a backup

Backing up the system


Mondo creates several different ways to make a backup. Because I'm using an sshfs mount, I will be using Hard Disk as the option:

2

Now we can select the location of the backups. This is where the bootable ISO images will be located:

3

The type of compression is personal. For me, the default option is good.

4

Maximum compression can take time, but it saves disk space.

5

The size is also something you need to define yourself. You can use the stock 4480 or you can change the size of it to something else. In this case I'm going to change it to 14000 but you can easily make it larger if you are going to use an external disk.

6

Now we can change the name to something you can recognize. You can use the server name, the ip address or something else that you can later recognize.

7

In most cases, it's best to use the / as the directory you wish to backup. There are exceptions, but changing this will result in a not bootable iso.

8

Here you can select all the folders you don't wish to backup. Be careful with this.

9

The temporary folder has to be located on the current system. This can't be in the sshfs folder that we mounted before.

10

You can put the scratch location on the sshfs share, like I'm doing here.

11

Extended attributes can be useful, especially with SElinux. This will take some extra time.

12

Your current kernel.

13

I'm a big fan of verification, especially with backups.

14

After pressing Yes, the backup will start.

15

16

When it's done, you should end up with a nice iso image that contains the data.

Restoring

Restoring is pretty easy. I'm using virtualbox for testing purposes in which I can boot directly of ISO. In other cases you might have to burn this to a DVD, put it on a harddisk or usb stick, and boot from there. After booting the iso (use the first iso first), you get to see the menu.

17

It's pretty clear what the options are. I'm running this in a fresh virtual machine, so I'm going to just nuke it.

18

After it's done you get a screen similar to this:

19

Type exit to reboot and you should get a screen similar to this:

20

Your restore is complete, your device is back up and running. Just check your logs for errors and use the machine.

Commandline

Now we know what options we want, we can use the options to create a nice way to do this without all the menu's.

First we are going to take the settings above and run this as a command.

You can find the options here: http://www.mondorescue.org/docs/mondoarchive.8.html

mondoarchive -O -V -p centos-mondo-backup$(date '+%d-%b-%Y') -i -E "/mnt" -I "/" -N -d '/mnt/backup' -s '14000m' -9 -G -S '/mnt/backup' -T '/tmp' -z   
#-O = create backup  
#-V = verify  
#-p = prefix name  
#-i = use ISO images  
#-E = directories to exclude  
#-I = path to backup  
#-N = exclude network directories  
#-d = backup device  
#-s = Maximum size  
#-9 = compression level 9, maximum compression  
#-G = use gzip because it's faster  
#-S = path of the scratch directory  
#-T = path of the temp directory  
#-z = save extended attributes  



Putting it all together

We can now make a simple script to create a full system backup

#!/bin/bash  
#  
# Mount sshfs (this requires the use of ssh keys)  
sshfs root@10.10.205.134:/mnt/backup /mnt/sda  
#  
# Create the backup  
mondoarchive -O -V -p centos-mondo-backup$(date '+%d-%b-%Y') -i -E "/mnt" -I "/" -N -d '/mnt/backup' -s '14000m' -9 -G -S '/mnt/backup' -T '/tmp' -z   
#-O = create backup  
#-V = verify  
#-p = prefix name  
#-i = use ISO images  
#-E = directories to exclude  
#-I = path to backup  
#-N = exclude network directories  
#-d = backup device  
#-s = Maximum size  
#-9 = compression level 9, maximum compression  
#-G = use gzip because it's faster  
#-S = path of the scratch directory  
#-T = path of the temp directory  
#-z = save extended attributes  
#  
# Unmount share  
umount /mnt/backup  
#  
# Send log file to mail address  
mail -s 'Mondo full backup' email@address.com < /var/log/mondoarchive.log  
#  
# Done!  



Now add this line to your crontab and you have automated a full backup of your device.

Comments

Written by Deepweb links -

"An other strategy is 1) to use [vmware-vdiskmanager -x 20Gb ""d:\your_virtual_harddisk.vmdk""] as noted above. 2) Download & mount the .iso file from www.sysresccd.org (a linux bootCD with handy tools) 3) Use gParted, and resize your primary NTFS partition to the new size of your virtual harddive. Works like a charm " Regards