User Tools

Site Tools


linux:backup_linux

Full recovery of your linux

Rear Backup

Packages also available for linux x84_64, ppc64 and ppc64le

http://relax-and-recover.org/

REAR will generate a bootable iso file (minimum image <100M), to recover your system, and a compressed tar file containing all other data.

First install rear and dependencies:

[root@rhlab1 ~]# yum -y install mkisofs genisoimage attr bind-utils rear

Configure rear using a NFS v4 mount point on nfssrv:

[root@rhlab1 ~]# cat /etc/rear/local.conf
# Default is to create Relax-and-Recover rescue media as ISO image
# set OUTPUT to change that
# set BACKUP to activate an automated (backup and) restore of your data
# Possible configuration values can be found in /usr/share/rear/conf/default.conf
#
# This file (local.conf) is intended for manual configuration. For configuration
# through packages and other automated means we recommend creating a new
# file named site.conf next to this file and to leave the local.conf as it is.
# Our packages will never ship with a site.conf.
OUTPUT=ISO
BACKUP=NETFS
BACKUP_URL=nfs://nfssrv/export/backup/linux
### Exclude certain items
ONLY_INCLUDE_VG=( ca )
EXCLUDE_MOUNTPOINTS=( /data )
BACKUP_PROG_EXCLUDE=( '/tmp/*' )

Test a backup using validation on each step:

[root@rhlab1 output]# rear -v -d -S -c /etc/rear mkbackup
Relax-and-Recover 1.17.2 / Git
Using log file: /var/log/rear/rear-rhldapr1.log
Press ENTER to include '/etc/rear/os.conf' ...
Press ENTER to include '/usr/share/rear/conf/Linux-ppc64le.conf' ...
Press ENTER to include '/usr/share/rear/conf/GNU/Linux.conf' ...
Press ENTER to include '/etc/rear/local.conf' ...
Press ENTER to include '/usr/share/rear/init/default/01_set_drlm_env.sh' ...
....

For production backup use, remove validation option and or verbose and debug:

rear -v -d -c /etc/rear mkbackup

Rear supports also most backup software like Bacula, TSM… A full sample config file is located in /usr/share/rear/conf/default.conf

Sample config file using TSM (dsm.opt and dsm.sys must be register):

[root@rhlab1 output]# cat /etc/rear/local.conf
OUTPUT=ISO
#BACKUP=NETFS
#BACKUP_URL=nfs://systemh/export/backup/linux
### Exclude certain items
ONLY_INCLUDE_VG=( ca )
EXCLUDE_MOUNTPOINTS=( /data )
### TSM
BACKUP=TSM
COPY_AS_IS_TSM=( /etc/adsm/TSM.PWD /opt/tivoli/tsm/client /usr/local/ibm/gsk8* )
COPY_AS_IS_EXCLUDE_TSM=( )
PROGS_TSM=(dsmc)
# Should the result from mkrecover/backup saved via TSM
TSM_RESULT_SAVE=y
# TSM archive management class definition
TSM_ARCHIVE_MGMT_CLASS=
# if TSM server confirms the backup was successful (to preserve space on the local system)
TSM_RM_ISOFILE=y
# where to copy the resulting files to and save them with TSM
TSM_RESULT_FILE_PATH=/opt/tivoli/tsm/rear

Rear for linux PPCle

For PPCle, the versiuon 2.0 or higher is required, else the iso will not be bootable. You can also download from Github, and do a make install

Add the following RPM package: redhat-lsb-core-*.ppc64le

Autoexclude_multipath is needed or REAR will exclude the multipathed disks. REAR_INITRD_COMPRESSION is needed otherwise the INITRD is too big for Power8 to boot from.

config file: site.conf

[root@centos01 ~]# cat /etc/rear/site.conf
OUTPUT=ISO
BACKUP=NETFS
BACKUP_URL="nfs://nfshost/export/rear/"
REAR_INITRD_COMPRESSION="lzma"
#BACKUP_PROG_INCLUDE=( '/' )
#ONLY_INCLUDE_VG=( ca )
#EXCLUDE_MOUNTPOINTS=( /data )
AUTOEXCLUDE_MULTIPATH=N
AUTOEXCLUDE_DISKS=Y

Create a backup

[root@centos01 ~]# rear -v mkbackup

Result on NFS server

[root@nfshost]/export/rear/centos01# ls -l
total 15614248
-rw-------    1 root     system          202 May 16 12:23 README
-rw-------    1 root     system          266 May 16 12:23 VERSION
-rw-------    1 root     system      3695059 May 16 12:33 backup.log
-rw-------    1 root     system   7933978880 May 16 12:33 backup.tar.gz
-rw-------    1 root     system     53102592 May 16 12:23 rear-centos01.iso
-rw-------    1 root     system       349619 May 16 12:23 rear-centos01.log

To restore, boot on iso image and do rear recover

You can also add an IP address by stopping boot process and add kernel options:

ip=10.10.1.100 nm=255.255.255.0 gw=10.10.1.1 netdev=eth0

To change disk layout before recovery https://github.com/rear/rear/blob/master/doc/user-guide/06-layout-configuration.adoc

Error on rear

Backup rear failed

[root@linux plugins]# /usr/sbin/rear -v mkbackup
ERROR: Cannot test if the ReaR recovery system is usable because /var/tmp is mounted 'noexec'
Aborting due to an error, check /var/log/rear/rear-bldnsr.log for details

The filesystem /tmp is mounted with noexec

[root@linux plugins]# mount | grep '/tmp'
/dev/mapper/rootvg-tmp on /tmp type xfs (rw,nosuid,nodev,noexec,relatime,attr2,inode64,logbsize=256k,sunit=512,swidth=512,noquota)

Use a filesystem which is not mounted with noexec parameter

[root@linux plugins]# export TMPDIR='/home' ; /usr/sbin/rear -v mkbackup

Or you can remount the filesystem /tmp this exec option

Rear Recovery

linux/backup_linux.txt · Last modified: 2021/01/01 21:25 (external edit)