SitefinderOracle and Sun
Secure Search

BigAdmin System Administration Portal
Community-Submitted Tech Tips
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Integrating Symantec Veritas NetBackup With ZFS Snapshots in the Solaris 10 OS

Matthew Hoskins, August 2008

File system snapshots are the bomb. Snapshots are one of those things that you can't see how you lived without, once you start using them. The ZFS file system has a particularly good implementation of snapshots. But how do we use them for backups?

If you are using Symantec Veritas NetBackup, the answer might not be so obvious. At this time, there isn't really very much in the way of out-of-the-box integration with ZFS. So we have to fill in with a little scripting. Luckily, it's pretty easy.

We will use a specific example of a system serving up home directories on ZFS. We want Symantec Veritas NetBackup to initiate a snapshot before it begins backing up data. This snapshot will be mounted in a standardized location. We want to make restores easy, so certain information about the ZFS file system will also be embedded.

Note: This solution was tested with Symantec Veritas NetBackup 6.0 MP5 and the Solaris 10 11/06 Operating System. However, any Symantec Veritas NetBackup 4.5+ version and any Solaris version with ZFS snapshots and cloning should work.

Snapshot Script

First of all, we need a mechanism to create snapshots in an automated fashion. I wrote a small script called zfs.roll.snapshot. It will create (or recreate, if it already exists) a ZFS snapshot, and then use the ZFS "clone" functionality to automatically mount the snapshot in an alternate location. This process prevents you from having to point the backup software at a .zfs/snapshot directory, which is clumsy.

By default the script will mount the clone under /zbackup, although this behavior can be changed with options or by editing the script. Because a ZFS clone is created using the same type of copy-on-write pointers as the snapshot itself, it uses additional space only when data changes in the live volume.

Here's the source code for the script file: zfs.roll.snapshot. Please rename the file so it has a .sh extension instead of a .txt extension.

Install the script wherever you maintain scripts of this type. The /usr/local/sbin/ directory would be fine.

For demonstration, we will run the commands manually to show the script's operation:

# zfs.roll.snapshot /export/home daily.netbackup
zfs.roll.snapshot: No clone for mypool/home
zfs.roll.snapshot: Creating snapshot mypool/home@daily.netbackup
zfs.roll.snapshot: Creating clone
mypool/autosnapclone_home_daily.netbackup
zfs.roll.snapshot: Clone mounted as
/zbackup/daily.netbackup/mypool/home/export/home
zfs.roll.snapshot: Done.

# ls -l /export/home
total 87
drwxr-xr-x  82 matt     matt         142 Jul 11 19:57 frankie
drwxr-xr-x  95 mark     mark         162 Jul 12 18:35 mark
drwxr-xr-x  82 matt     matt         142 Jul 11 19:57 matt

# ls -l /zbackup/daily.netbackup/mypool/home/export/home/
total 87
drwxr-xr-x  82 matt     matt         142 Jul 11 19:57 frankie
drwxr-xr-x  95 mark     mark         162 Jul 12 18:35 mark
drwxr-xr-x  82 matt     matt         142 Jul 11 19:57 matt

Default operation requires two positional parameters:

  • First, the script needs the ZFS volume name or the mountpoint of a volume. The script looks up the ZFS volume from the mountpoint if necessary.
  • Second, it needs the name to use for the snapshot.

The snapshot name, ZFS pool name, ZFS volume name, and original mountpoint are used to compose the mountpoint for the snapshot clone. This embeds valuable information about where the data came from, which you can use in the event that you need to do a restore.

Symantec Veritas NetBackup Configuration

Next, we need to hook the zfs.roll.snapshot script into Symantec Veritas NetBackup's pre-backup scripting. This all happens in the /usr/openv/netbackup/bin directory, which is a standard location on all NetBackup Solaris clients.

The pre-backup scripts are very simple scripts, and they are well documented in the Symantec Veritas NetBackup documentation. (Use and customization of the template script is covered in the NetBackup 6.0 System Administrator's Guide for UNIX and Linux, Volume II, Chapter 5, page 260. This is available on product CDs and as a PDF.)

Create a script named bpstart_notify.MY_POLICY_NAME, where MY_POLICY_NAME is the name of the Symantec Veritas NetBackup policy. This script will be called before the backup job starts copying data. Our script looks like this:

#!/bin/sh
###############################################################
# Per-POLICY/Client NB Backup start script
###############################################################
umask 022
# Parameters passed are:
CLIENTNAME="$1"
POLICYNAME="$2"
SCHEDNAME="$3"
SCHEDTYPE="$4"
# ENV Vars
# BACKUPID
# RESTARTED (0=First run, Not Restarted, 1=Restarted job)

CMAILER=/usr/local/sbin/cmailer
ZFSROLLSNAPSHOT=/usr/local/sbin/zfs.roll.snapshot

$ZFSROLLSNAPSHOT /export/home  daily.netbackup \
> /var/log/home.zfs.reclone.log 2>&1

exit 0

You might have to modify the paths in the bpstart_notify script to match the location where you have scripts installed. The script above is kept simple for ease of reading. You might want to specify an alternate location for the logs or direct the output to email.

Obviously, if you are backing up your data from /zbackup, you will want to add the live mountpoints to the Symantec Veritas NetBackup exclude lists. Doing this will prevent the data from getting backed up twice. Symantec Veritas NetBackup exclude lists live under /usr/openv/netbackup as exclude_list or exclude_list.POLICY_NAME.

If you have multiple backup policies backing up data, you might need to carefully construct exclude lists and the paths specified under the Symantec Veritas NetBackup policy.

The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource.
 
 

Comments (latest comments first)

Discuss and comment on this resource in the BigAdmin Wiki

Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
BigAdmin Upgrade Hub
 
 
Oracle - The Information Company