Online Backup Copies of a Live Volume

Regularly backing up volumes that contain sensitive data is a must. In doing so, the desktop database is also saved. However problems may arise if the desktop database is being changed while it is saved, due to file changes by the HELIOS file servers. When restoring the backup to the volume, the database may be inconsistent, which will lead to failures or error messages.

One workaround is to make the volume inactive during the time span of the backup by using the srvmsg -c -n desksrv freeze [duration] command.

An online “.Desktop” backup copy can be done with the following script:

(The script can be called on the command line via perl backup-desktop.pl)

 

#!/usr/bin/perl -w

# This script uses the new desksrv feature of CD024 UB+

# to flush and then freeze the desktop database for a

# certain amount of time, during which it can be savely

# copied.

# The script can be called on the command line via perl
# backup-desktop.pl and optionally a freeze time, e.g.
# 20 seconds: "perl backup-desktop.pl 20"
# If a parameter is omitted, the default value will be

# used

# NOTE: This is only an example, the path to the HELIOS

# volume and the destination directory must be adjusted

# to your needs.

# Path to the HELIOS volume:
my $volpath = "/usr/local/helios/public";
# Where to store the backup copy:
my $dest = "/tmp/";

my $heliosdir;
my $errcode = 0;

my ($FreezeTime, $FreezeMax, $FreezeDefault)=(0,60,10);

if ($#ARGV < 0) {
    $FreezeTime=$FreezeDefault;
    print "No freeze time specified, using default of $FreezeTime\n;"
} else {
    $FreezeTime=$ARGV[0];
    if ($FreezeTime>=$FreezeMax) {
        printf ("FreezeTime (%d) > FreezeMax (%d), using new value: %d\n;",$FreezeTime, $FreezeMax, $FreezeMax);
        $FreezeTime=$FreezeMax;
    } else {
        print "Using specified freeze time of $FreezeTime\n;"
    }
}

if (not -f "$volpath/.Desktop") {
    die "No .Desktop in <$volpath>\n;"
}

# Find the HELIOS installation directory.
open (FD, "/etc/HELIOSInstallPath") ||
    die "Cannot find HELIOS product, check installation\n;"
chop($heliosdir = <FD>);
close(FD);

# add sleep second after srvmsg call to FreezeTime
$FreezeTime+=1;

# Let the desksrv flush and freeze the database.
system("$heliosdir/bin/srvmsg", "-c", "-n", "desksrv", "freeze", "$FreezeTime");
sleep 1;

$cpStart=time;
# Database is frozen and can be copied.
system("/bin/cp", "-p", "$volpath/.Desktop", $dest);
$cpEnd  =time;

$cpTime = $cpEnd - $cpStart;

if ($cpTime>($FreezeTime)) {
    print "The time to copy took longer ($cpTime) than $FreezeTime seconds\n;"
    $errcode=1;
} else {
    print "The time to copy took less ($cpTime) than $FreezeTime seconds\n;"
}

exit $errcode;