Nbackup

From MicroFocusInternationalWiki
Jump to: navigation, search

Backup / Restore Using NBACKUP and TAR

OES on SLES comes with a built-in NSS-aware backup & restore utility, named nbackup. Some information on its use can be found below, in addition to the man page for the utility.


Backing-up an NSS Mount Point to File using NBackup

Sample Command Line:

  • /opt/novell/sms/bin/nbackup -cvf backup.sidf -U .adminuser.context -P linuxadmin /media/nss/DATA

This will backup the mount point contents to a sidf file called "backup.sidf". The same can be used for restore. You need to use a username that exist in eDirectory as you are using SMS to backup

Restoring an NSS Mount Point from File using NBackup

Sample Command Line:

  • /opt/novell/sms/bin/nbackup -xvf backup.sidf -U .adminuser.context -P linuxadmin -r "/media/nss/DATA /media/nss/NSSDEST"

You need to use a username that exist in eDirectory as you are using SMS to backup.

This command will restore the contents of backup.sidf to a renamed destination /media/nss/NSSDEST. If no rename is required, then the -r and the following parameter can be ignored.

Backing-up an NSS Mount Point to Tape Device

Sample Command Line:

  • /opt/novell/sms/bin/nbackup -cvf /dev/nst0 -U root -P linuxadmin /media/nss/DATA

This will backup the mount point contents to non-rewinding tape device /dev/nst0.

NOTE: You may wish to ensure the tape is rewound before executing this command, via mt -f /dev/nst0 rewind.

Verifying Contents of a Backup/File using NBackup

Sample Command Line:

  • Using sidf File:
    • /opt/novell/sms/bin/nbackup -tvf backup.sidf
  • Using tape:
    • /opt/novell/sms/bin/nbackup -tvf /dev/nst0
      • Tape must be positioned at the start of the backup session. See mt info below for more details.


Backing Up a Complete System Using tar and nbackup

For systems with attached tape drives, such as the IBM 400/800GB Ultrium LTO3, full backups can be accomplished using tar and nbackup, via the following (quaint) shell script:

backup.sh - Backup script

#!/bin/bash
rm /var/log/nightly-backup.*
echo "@Backup Begins ====================" > /var/log/nightly-backup.log
date >> /var/log/nightly-backup.log
date > /var/log/nightly-backup.errors
mt -f /dev/nst0 rewind >> /var/log/nightly-backup.log 2>> /var/log/nightly-backup.errors
echo "-- System backup" >> /var/log/nightly-backup.log
tar cvf /dev/nst0 --label="System Backup - `date '+%d-%B-%Y'`" --totals -X /etc/backup.excludes / >> /var/log/nightly-backup.log 2>> /var/log/nightly-backup.errors
echo "-- NSS Backup" >> /var/log/nightly-backup.log
/opt/novell/sms/bin/nbackup -cvf /dev/nst0 --label="NSS Backup - `date '+%d-%B-%Y'`" -U local-linux-admin-user -P password /media/nss/MOUNTPOINT/ >> /var/log/nightly-backup.log 2>> /var/log/nightly-backup.nss
echo "-- Rewinding and Ejecting Tape" >> /var/log/nightly-backup.log
mt -f /dev/nst0 rewoff >> /var/log/nightly-backup.log 2>> /var/log/nightly-backup.errors
date >> /var/log/nightly-backup.log
echo "@Backup Ends ====================" >> /var/log/nightly-backup.log

This file can be placed in /etc/cron.d, and scheduled accordingly. When creating this file, be sure to make it executable (i.e. chmod 777 backup.sh).

Exclude file - /etc/backup.excludes

This file simply lists patterns for tar to exclude. An example is as follows:

/media/*
/_admin/*
/sys/*
/tmp/*
/proc/*
/mnt/*

NOTE: Ensure that there are no empty lines in this file, otherwise no files will be backed up. NOTE: The tar program will be work correct at version 1.14

Scheduling via /etc/crontab

Add the following lines to the /etc/crontab file to facilitate nightly backups beginning at midnight.

#
# Nightly Backup & Maintenance items
#
0 0 * * *       root  /etc/backup.sh

Restoring from Tape Backup

Similar syntax, probably executed manually.

  • mt -f /dev/nst0 rewind
  • tar xvpf /dev/nst0
  • /opt/novell/sms/bin/nbackup -xvf /dev/nst0 -U local-linux-admin-user -P password -r "/media/nss/MOUNTPOINT /media/nss/NEWDEST"
  • NOTES:
    • The tar operation restores files to exactly their old location. The nbackup operation allows you to redirect the restore to another location.
    • If restoring from NSS only, and your backups use the script provided above, always use the mt command to skip the first file on tape - this will always be OS files in TAR format.
      • e.g. mt -f /dev/nst0 rewind ; mt -f /dev/nst0 fsf 1

References

  • MAN pages
    • tar
    • mt
    • nbackup