Aaron,

  I would LOVE to share the iscsi volume.  Whats the best way to do that? :)

Here is my script (dirty but works):

#!/usr/bin/perl
use Getopt::Long;
use Cwd;
# Define variables
# retention period
$retention = 40;
# two expected days
$d1 = "Mon";
$d2 = "Thu";
# backuplog file name
$log = "mnt/backuplog.txt";
# Change to /root/scripts/backup
$dir = "/root/scripts/backup/";
chdir $dir;
# Pull CLI options
GetOptions ('day=s' => \$day);
# Perform Time operations
my $now = localtime time;
my ($bsec,$bmin,$bhour,$bmday,$bmon,$byear,$bwday,$byday,$bisdst) =
localtime time;
$c="/bin/date \+%a";
$vtime=qx($c);chomp $vtime;

#Define where to write snapshot to
if ($vtime eq $d2){$destination="/dev/lacievg/lacie2";}
elsif ($vtime eq $d1){$destination="/dev/lacievg/lacie1";}
else {print "wrong day\n";exit;}

# Mount up Lacie
mountup();
# Perform Sanity Checks
checksanity();
# If things are OK, update the maintenance partition
recordtimes();
# Perform the copy
mirror();
# Email Results
emailresults();
# Umount
unmount();
sub mirror{
       system ("/usr/sbin/lvcreate -L200G -s -n esxbackup
/dev/velirvg1/esxstore1 >> $log");
       system ("time /bin/dd bs=8M if=/dev/velirvg1/esxstore1
of=$destination >> $log");
       backuplog("backups complete",$log,">>");
       }
sub mountup{
       system ("/sbin/vgscan");
       system ("/sbin/vgchange -a y lacievg");
       system ("/bin/mount /dev/sdd1 $dir/mnt");
       }
sub checksanity{
       # hack to see if the lacie mounted properly by checking a file
       $c="/bin/cat $dir/mnt/lastbackup.txt";
       $lastbackup=qx($c);chomp $lastbackup;
       $lastbackuplength= length($lastbackup);
       if ($lastbackuplength < 5){
               emailbad("Backups Aborted, lastbackuplength is
$lastbackuplength");
               exit;
               }
       # check to see if the Lacie has ben rotated
       if ($vtime eq $d1){
               print "vtime is $vtime\n";
               print "lastbackup is $lastbackup\n";
               $name = "$dir/mnt/lastbackup.txt";
               $modded = -M $name;
               $m=int($modded);
               backuplog($now,$log,">");
               backuplog("backup last ran $m days ago",$log,">>");
               if ($m > $retention){
                       emailbad("Hello, my name is Lacie, you have not
rotated me in $m days ");
                       }
               }
       if ($vtime eq $d2){
               print "vtime is $vtime\n";
               print "lastbackup is $lastbackup\n";
               $name = "$dir/mnt/lastbackup.txt";
               $modded = -M $name;
               $m=int($modded);
               backuplog($now,$log,">");
               backuplog("backup last ran $m days ago",$log,">>");
               if ($m > $retention){
                       emailbad("Hello, my name is Lacie, you have not
rotated me in $m days ");
                       }
               }
       }
sub backuplog{
       $string = shift;
       $file = shift;
       $operation = shift;
       system ("/bin/echo $string $operation $file");
       print ("/bin/echo $string $operation $file\n");
       }

sub recordtimes{
       system ("/bin/echo $now >> mnt/backuplogtime.txt");
       backuplog("writing to $destination",$log,">>");
       system ("/bin/echo $now > mnt/lastbackup.txt");

       }
sub emailbad{
       # Email error
       $message =shift;
       print $message,"\n";
       system ("/bin/echo $message > /tmp/message");
       system ("/bin/mail -s lvmbackups [EMAIL PROTECTED] < /tmp/message");
       system ("/bin/mail -s lvmbackups [EMAIL PROTECTED] < /tmp/message");

       }

sub emailresults{
       # Email out
       system ("/bin/mail -s lvmbackups [EMAIL PROTECTED] < mnt/backuplog.txt");
       system ("/bin/mail -s lvmbackups [EMAIL PROTECTED] < mnt/backuplog.txt");
       }

sub unmount
       {
       # Unmount
       system ("/usr/sbin/lvremove -f /dev/velirvg1/esxbackup >> $log");
       system ("/sbin/vgchange -a n lacievg");
       system ("/bin/umount /dev/sdd1");
       }


On Fri, Apr 4, 2008 at 1:43 PM, Aaron Stranberg <[EMAIL PROTECTED]>
wrote:

> Seems that you could just share out a new iscsi lun, but I may not
> completely understand what you are trying to do.  Any chance you would share
> your  script?
>
> -Aaron
>
> On Fri, Apr 4, 2008 at 12:05 PM, Vasiliy Boulytchev <
> [EMAIL PROTECTED]> wrote:
>
> > Gents,
> >   Can you please comment on the best way to accomplish the following?
> >
> >   We currently have a 1TB volume exported via iscsi on Openfiler
> > (v2.2).  The file system is vmfs (esx servers).
> >   I wrote a perl script to capture a snapshot of this logical volume,
> > and 'dd' it to a secondary storage device on openfiler.
> >
> >   What is the best way to export/share this new backup volume?  In case
> > I want to restore an old VM, etc.
> >
> > Thanks,
> >
> > Vasiliy Boulytchev
> >
> > _______________________________________________
> > Openfiler-users mailing list
> > [email protected]
> > https://lists.openfiler.com/mailman/listinfo/openfiler-users
> >
> >
>
_______________________________________________
Openfiler-users mailing list
[email protected]
https://lists.openfiler.com/mailman/listinfo/openfiler-users

Reply via email to