Relax and Recover - jrwhetse/jrwhetse.github.io GitHub Wiki

Relax and Recover (REAR)

Overview

Relax-and-Recover is the leading Open Source bare metal disaster recovery and system migration solution. This utility is used to back up the bare metal database machines. The backup consists of an iso and a tar.gz compressed bundle of all contents on local mounts. Both the iso and the compressed archive are copied to a centralized location (destination) for backups. A rear user must be created and ssh key authorization setup.

References

GitHub: https://github.com/rear/rear

Documentation: https://github.com/rear/rear/blob/master/doc/user-guide/03-configuration.adoc

RHEL

Installation

yum install rear -y

rear

rpm -ql rear

# configuration file
/etc/rear/local.conf

# daily backup cron job
/etc/cron.d/rear

Configuration

Create User

If not already created, request a user to be created with username of rear to be used for backup procedures.

Setup SSH Key Authorization.

On the source machine, run the following to generate a RSA public/private key pair

[rear@source ~]# ssh-keygen -t rsa

Create the ~./.ssh directory on the backup destination host.

[rear@source ~]# ssh rear@destination mkdir -p .ssh

Copy the generated RSA public/private key pair

[rear@source ~]# cat .ssh/id_rsa.pub | ssh rear@destination 'cat >> .ssh/authorized_keys'

Set permissions

[rear@source ~]# ssh rear@destination "chmod 700 .ssh; chmod 640 .ssh/authorized_keys"

Test Login

[rear@source ~]# ssh rear@destination

local.conf

# /etc/rear/local.conf

#################
# Global
#################

# set temp directory
TMPDIR="/tmp"

# iso and archive file name
HOSTNAME="$(hostname -s 2>/dev/null || uname -n | cut -d. -f1)"

# user
USER=rear

# backup location
BACKUP_HOST=xx.xx.xx.xx

################
# Rescue Media
#################

# preferred boot method
OUTPUT=ISO

# output location
OUTPUT_URL=rsync://$USER@$BACKUP_HOST/rear/$HOSTNAME/

# iso filename
ISO_PREFIX=$HOSTNAME

#################
# Backup Stategy
#################

# backup/restore strategy
BACKUP=EXTERNAL

# exclude list
EXTERNAL_EXCLUDE="--exclude=/[dir1] --exclude=/[dir2]"

# backup command
EXTERNAL_BACKUP="tar -cvpz --warning=no-xdev --sparse --block-number --totals --verbose --no-wildcards-match-slash --one-file-system --ignore-failed-read $EXTERNAL_EXCLUDE / | ssh -T $USER@$BACKUP_HOST '( cat > /rear/$HOSTNAME/$HOSTNAME.tar.gz )';"

# Command to restore the data (by default $TARGET_FS_ROOT is '/mnt/local')
EXTERNAL_RESTORE="ssh -T $USER@$BACKUP_HOST cat /rear/$HOSTNAME/$HOSTNAME.tar.gz | (tar -xvzf - -C /mnt/local/)"

# Command to verify the availability of the backup resource, will be executed only if PING=1
# NOTE: This command will be run within the ProgressBar system !! You should therefore avoid
# output on STDOUT by rerouting that to FD 8, the progress bar
EXTERNAL_CHECK="ssh $USER@$BACKUP_HOST date >&8"

CronJob

The cronjob located in /etc/cron.d/rear and is created during RPM installation. For each environment, the cronjob kicks off the backup using the following command on the following schedule.

# /etc/cron.d/rear

# Sunday at 2am
# 0 1 * * 0 root /usr/sbin/rear -v mkbackup
#
# Monday at 2am
# 0 1 * * 1 root /usr/sbin/rear -v mkbackup

Restore from backup

  1. Using an OPS machine, SCP the backup ISO to the local machine.

    scp [user]@[host]:/rear/[host].iso .

  2. Using the Infinicenter Plugin Console, Mount the ISO

  3. Reboot and select Recover from the ISO menu

  4. At the prompt, type rear recover to begin the recovery process.

  5. Once completed, reboot.

  6. Please see the following demonstration for complete example: https://www.youtube.com/watch?v=oibXzZYURYg

⚠️ **GitHub.com Fallback** ⚠️