About

I have written this system backup script because none of the freely available scripts fitted my exact needs. The run_aix_system_backup.sh script provides a centralized backup & recovery method involving a NIM master or any other available NFS server.

Code

Make sure you check and customize the parameters at the beginning of the script!

Download the script from following GitHub repository: https://github.com/patvdv/aix_scripts

Features

  • Support for AIX & VIOS hosts.
  • Use of specific VIOS backup tools (iosbackup, viosbr …).
  • Support for local, NFS based backups (NIM or other targets). Don’t use local unless required since a local backup may be totally useless for recovery!
  • Support for 2 generations of backups.
  • Saving of LPAR profile data (IVM only).
  • Simple error alerting via mail.

Configuration

Have a look at the configuration stanza in the script and validate if/what needs to be retro-fitted to your environment:

# ------------------------- CONFIGURATION starts here -------------------------
# specify the UNIX user that needs to be used for executing the script
EXEC_USER="root"
# default list of recipients receiving error/warning e-mails
TO_MSG="foo@bar.com"
# location of log directory (default), see --log-dir)
LOG_DIR="/var/log"
# location of temporary working storage
TMP_DIR="/var/tmp"
# ------------------------- CONFIGURATION ends here ---------------------------

Dependencies/Requirements

  • AIX (tested on AIX 6.x)
  • Korn shell
  • mksysb, iosbackup, viosbr & bkprofdata utilities
  • a working NIM master and/or NFS server
  • AutoFS or NFS

Usage

# ./run_system_aix_backup.sh --

**** run_aix_system_backup.sh ****
**** (c) KUDOS BVBA - UNIX (Patrick Van der Veken) ****
Performs an mksysb, backupios, viosbr backup of an AIX/VIOS host to a
local, NIM-based or NFS location; optionally creates a snap of the host.

Syntax: ./run_aix_system_backup.sh [--help] | [--version] | (--local-dir=<local_directory> |
		--use-nfs --nfs-dir=<remote_directory> |
		--use-nim --nim-dir=<remote_directory>)
			[--is-vios [--is-ivm]]
			[--make-snap] [--no-log] [--log-dir=<log_directory>]
			[--send-alert [--mail-to=<address_list>]]

Parameters:

--is-ivm     : perform a bkprofdata backup for VIOS using IVM (non-HMC)
--is-vios    : perform a backup using viosbr (IOS 2.1+) and backupios tools if the client host is a VIO server.
--local-dir  : location of the save directory on a local filesystem.
--log-dir    : specify a log directory location.
--mail-to    : list of e-mail address(es) to which e-mails will to be send to.
--make-snap  : make an AIX snap (cfr. IBM support).
--nfs-dir    : location of the save directory on the NFS server. Format must be in typical NFS mount notation,
			   i.e. nfs_srv:/nfs_dir.
--nim-dir    : location of the save directory on the NIM master server. Client hostname is automatically appended
			   to the given value when automounting the directory.
--no-log     : do not log any messages to the script log file.
--send-alert : alert via e-mail upon occurrence of errors/warnings.
--use-nfs    : create the backup on a NFS mount shared by an NFS server. See Pre-requisites section below.
--use-nim    : create the backup on a NFS mount shared by the NIM master. See Pre-requisites section below.
--version    : show the script version/release/fix

Pre-requisites for the NIM method:

1) NIM master must be configured to allow NFS mount from the client to the remote
target directory. The NFS mount name must end in the NIM client's hostname
(see /etc/xtab, /etc/exports on NIM master).
2) NIM client (this host) must have AutoFS configured & active for /net
(see /etc/auto_master).
3) A correctly configured /etc/niminfo file on the NIM client.

Pre-requisites for the NFS method:
1) NFS server must be configured to allow NFS mount from the client to the remote
target directory (see /etc/xtab, /etc/exports on NFS server)

Note 1: NIM & NFS methods both employ a remote NFS mount for storage and as such they operate
in a similar manner. The NIM method differs in that it will try auto-discover which
host is the NIM master. In both cases you must have forward & reverse naming resolution
working correctly!

Note 2: please make sure sufficient disk space is available at the save location to hold
3 generations of backups during execution of the script. Only 2 generations will
be available at any given time (one being temporary). You will find these generations
as the 'prev' and 'curr' directory sets in the save location.

Examples

Using a NFS based location

# ./run_aix_system_backup.sh --use-nfs --nfs-dir=aixnim:/export/images/aix --make-snap

INFO: *** start of run_aix_system_backup.sh [--use-nfs --nfs-dir=aixnim:/export/images/aix --make-snap] ***
INFO: logging takes places in /var/log/run_aix_system_backup.sh.log
INFO: using NFS mount for backup
INFO: NFS directory aixnim:/export/images/aix mounted onto /var/tmp/6094892
INFO: VIOS check: running on regular AIX host or no '--is-vios' given
INFO: starting the MKSYSB backup in /var/tmp/6094892/run_aix_system_backup.sh.6094892 ...
INFO: MKSYSB file created at /var/tmp/6094892/run_aix_system_backup.sh.6094892/aix.mksysb
INFO: requested a SNAP, creating one at the default location ...
INFO: SNAP file created and moved to /var/tmp/6094892/run_aix_system_backup.sh.6094892
INFO: rotating backup generations ...
INFO: available backup(s) are now:
INFO: drwx------ 2 root system 256 Apr 04 11:19 /var/tmp/6094892/curr
INFO: drwx------ 2 root system 256 Apr 02 07:09 /var/tmp/6094892/prev
INFO: performing cleanup ...
INFO: trying to unmount /var/tmp/6094892
INFO: succesfully unmounteded /var/tmp/6094892
INFO: /var/tmp/.run_aix_system_backup.sh.lock lock directory removed
INFO: *** finish of run_aix_system_backup.sh [--use-nfs --nfs-dir=aixnim:/export/images/saix --make-snap] ***

Backing up up a VIOS (IVM)

VIOS:> ./run_aix_system_backup.sh --use-nfs --nfs-dir=aixnim:/export/images/aixvios --is-vios --is-ivm

INFO: *** start of run_aix_system_backup.sh [--use-nfs --nfs-dir=aixnim:/export/images/aixvios --is-vios --is-ivm] ***
INFO: logging takes places in /var/log/run_aix_system_backup.sh.log
INFO: using NFS mount for backup
INFO: NFS directory aixnim:/export/images/aixvios mounted onto /var/tmp/7995408
INFO: VIOS check: running on a VIO server [2.2.0.13-FP24 SP-03]
INFO: starting the VIOSBR backup in /home/padmin/cfgbackups ...
INFO: VIOSBR file created and copied to /var/tmp/7995408/run_aix_system_backup.sh.7995408
INFO: starting the BKPROFDATA backup in /home/padmin ...
INFO: BKPROFDATA file created and copied to /var/tmp/7995408/run_aix_system_backup.sh.7995408
INFO: starting the BACKUPIOS backup in /var/tmp/7995408/run_aix_system_backup.sh.7995408 ...
INFO: BACKUPIOS file created at /var/tmp/7995408/run_aix_system_backup.sh.7995408/aixvios.backupios
INFO: rotating backup generations ...
INFO: available backup(s) are now:
INFO: drwx------ 3 root system 256 Feb 22 13:25 /var/tmp/7995408/curr
INFO: performing cleanup ...
INFO: trying to unmount /var/tmp/7995408
INFO: succesfully unmounteded /var/tmp/7995408
INFO: /var/tmp/.run_aix_system_backup.sh.lock lock directory removed
INFO: *** finish of run_aix_system_backup.sh [--use-nfs --nfs-dir=aixnim:/export/images/aixvios --is-vios --is-ivm] ***

Using the AutoFS and niminfo

# ./run_aix_system_backup.sh --use-nim --nim-dir=/export/images

INFO: *** start of run_aix_system_backup.sh [--use-nim --nim-dir=/export/images --make-snap] ***
INFO: logging takes places in /var/log/run_aix_system_backup.sh.log
INFO: using NIM mount for backup
INFO: VIOS check: running on regular AIX host or no '--is-vios' given
INFO: starting the MKSYSB backup in /net/aixnim/export/images/aix2/run_aix_system_backup.sh.50331760 ...
INFO: MKSYSB file created at /net/aixnim/export/images/aix2/run_aix_system_backup.sh.50331760/aix2.mksysb
INFO: requested a SNAP, creating one at the default location ...
INFO: SNAP file created and moved to /net/aixnim/export/images/aix2/run_aix_system_backup.sh.50331760
INFO: rotating backup generations ...
INFO: available backup(s) are now:
INFO: drwx------ 2 root system 256 Mar 23 07:05 /net/aixnim/export/images/aix2/curr
INFO: drwx------ 2 root system 256 Mar 8 07:05 /net/aixnim/export/images/aix2/prev
INFO: performing cleanup ...
INFO: /var/tmp/.run_aix_system_backup.sh.lock lock directory removed
INFO: *** finish of run_aix_system_backup.sh [--use-nim --nim-dir=/export/images --make-snap] ***

Leave a comment