MKSYSB Backup:
MKSYSB is a bootable backup of the root volume group (rootvg) on AIX.
It contains OS files, configuration, and can be used to restore or clone the system.
MKSYSB Backup Command
Example:
# mksysb -i -X /backup/mksysb_$(hostname)_$(date +%Y%m%d).mksysb
This creates a backup file with the hostname and date in the filename, e.g., /backup/mksysb_appserver1_20251015.mksysb.
Useful Options:
-i: Creates an incremental backup if applicable (saves time and space).
-X: Excludes the /home directory (if you want to exclude user data).
-e: Excludes specific files or directories.
-c: Performs consistency check before backup.
MKSYSB Backup Script:
1.Jump server & aix servers should have passwordless authentication.
2.The script will mount NFS shared to AIX servers
3.To take mksysb(roovg) backup to the NFS shared
4.Unmount NFS shared
5.Run script ./remote_backup_aix_mksysb.sh <server1> <server2> <server3> ...
Example Script: remote_backup_aix_mksysb.sh
--------------------------------------------------------------------------------------------------------------
#!/bin/bash
# ===== CONFIG =====
REMOTE_USER="root"
NFS_SERVER="192.168.10.11"
NFS_PATH="/aix/backup"
MOUNT_POINT="/mnt"
# ===== CHECK INPUT =====
if [ $# -lt 1 ]; then
echo "Usage: $0 <server1> <server2> <server3> ..."
exit 1
fi
# ===== LOOP THROUGH ALL SERVERS =====
for REMOTE_HOST in "$@"
do
echo "==============================================="
echo "Starting backup on: ${REMOTE_HOST}"
echo "==============================================="
ssh -o BatchMode=yes ${REMOTE_USER}@${REMOTE_HOST} << EOF
echo "Connected to \$(hostname)"
nfso -o nfs_use_reserved_ports=1
# Check if already mounted
if mount | grep " ${MOUNT_POINT} " > /dev/null 2>&1
then
echo "${MOUNT_POINT} already mounted.............."
else
echo "Mounting NFS share.........................."
mount ${NFS_SERVER}:${NFS_PATH} ${MOUNT_POINT}
if [ \$? -ne 0 ]; then
echo "ERROR: Mount failed....................."
exit 1
fi
fi
HOSTNAME=\$(hostname)
DATE=\$(date +%Y%m%d)
BACKUP_DIR=${MOUNT_POINT}/backup
BACKUP_FILE=\${BACKUP_DIR}/mksysb_\${HOSTNAME}_\${DATE}.mksysb
mkdir -p \${BACKUP_DIR}
echo "Starting mksysb backup..."
mksysb -i -X \${BACKUP_FILE}
if [ \$? -ne 0 ]; then
echo "ERROR: mksysb failed."
exit 1
fi
echo "Backup completed successfully."
echo "Unmounting ${MOUNT_POINT}..."
umount ${MOUNT_POINT}
if [ \$? -ne 0 ]; then
echo "WARNING: Unmount failed....."
fi
echo "Finished on \$(hostname)"
exit 0
EOF
if [ $? -eq 0 ]; then
echo "SUCCESS: ${REMOTE_HOST} backup completed."
else
echo "FAILED: ${REMOTE_HOST} backup failed."
fi
echo ""
done
echo "All servers processed...................."
--------------------------------------------------------------------------------------------------------------
SAVEVG Backup:
savevg is an AIX command used to create a backup of a volume group (VG), including all logical volumes and data in that VG.
- Backing up entire volume groups before making changes.
- Migrating volume groups.
- Disaster recovery.
Basic syntax:
# savevg -f <backup_file_path> <vgname>
-f <backup_file_path>: Specifies the path and filename where the VG backup will be saved.
<vgname>: Name of the volume group you want to back up.
Tar Backup:
tar (tape archive) bundles multiple files/directories into a single archive file.
Often used with compression (gzip or bzip2) to save space.
Basic tar backup command
To create a backup archive of a directory, for example /home:
# tar -cvf /backup/home_backup_$(date +%Y%m%d).tar /home
-c = create a new archive
-v = verbose (lists files as they're archived)
-f = specifies the filename of the archive
Compressing the tar archive with gzip
# tar -czvf /backup/home_backup_$(date +%Y%m%d).tar.gz /home
-z = compress the archive using gzip
Compressing the tar archive with bzip2 (better compression)
# tar -cjvf /backup/home_backup_$(date +%Y%m%d).tar.bz2 /home
-j = compress using bzip2
Extracting from a tar archive
Without compression:
# tar -xvf archive.tar
With gzip compression:
# tar -xzvf archive.tar.gz
With bzip2 compression:
# tar -xjvf archive.tar.bz2
Example: Backup /etc directory to compressed archive
# tar -czvf /backup/etc_backup_$(date +%Y%m%d).tar.gz /etc
No comments:
Post a Comment