#!/usr/bin/perl ### # Create a Shadow Volume ### print "Enter Primary NSS Volume Name:"; my $pri = ; chomp ($pri); print "Enter Secondary NSS Volume Name:"; my $s = ; chomp ($s); my $sec= "/media/nss/$s"; open ("fd", ">>/etc/opt/novell/ncp2nss.conf"); print fd ("EXCLUDE_VOLUME $s"); close(fd); system ("/etc/init.d/ncp2nss restart"); print "ncpcon create shadow_volume $pri $sec\n"; system ("ncpcon create shadow_volume $pri $sec"); print "Shadow relation is created between $pri as primary and $s as shadow volume\n"; system ("/opt/novell/ncpserv/sbin/modprobe fuse"); system ("./opt/novell/ncpserv/sbin/shadowfs"); print "Shadow File System is configured between $pri and $s volumes\n"; while (1) { print "\n1 List Primary volume\n2 List Shadow Volume\n3 Move to Primay Volume\n4 Move to Shadow volume\n5 Remove Shadow Volume\n0 exit\n"; print "Enter Choice:"; my $ch = ; chomp ($ch); #print "Enterd choice is: $ch\n"; if ($ch == 1) { system ("ncpcon shadow $pri operation=lp"); } elsif ($ch == 2) { system ("ncpcon shadow $pri operation=ls"); } elsif ($ch == 3) { print "\n1 Based on pattern\n2 Based on time period\n3 Based on file size\n"; my $opt= ; chomp ($opt); if ($opt == 1) { print "\nEnter pattern of the file(s) to be moved to Primary Volume:"; my $pat= ; chomp ($pat); system ("ncpcon shadow $pri operation=mp pattern=$pat"); } elsif ($opt == 2) { print "\na: winthin last day\nb: 1 day to 1 week\nc: 1 week to 2 weeks\nd: 2 weeks to 1 month\ne: 1 month to 2 months\nf: 2 months to 4 months\ng: 4 months to 6 months\nh: 6 months to 1 year\ni: 1 year to 2 years\nj: More than 2 years"; my $pat= ; chomp ($pat); if ($pat =~ /^.$/ && $pat =~ /^[a-j]$/i ){ system ("ncpcon shadow $pri opeartion=mp range $pat"); } else { print "Invalid choice \n"; } } elsif ($opt == 3) { print "\na: Less than 1KB\nb: 1KB to 4KB\nc: 4KB to 16KB\nd:16KB to 64KB\ne:64KB to 256KB\nf: 256KB to 1MB\ng: 1MB to 4MB\nh:4MB to 16MB\ni:16MB to 64MB\nj:64MB to 256MB\nk:More than 64MB\n"; my $pat= ; chomp ($pat); if ($pat =~ /^.$/ && $pat =~ /^[a-k]$/i ){ system ("ncpcon shadow $pri opeartion=mp range $pat"); } else { print "Invalid choice \n"; } } else { print "Invalid choice \n"; } } elsif ($ch == 4) { print "\n1 Based on pattern\n2 Based on time period\n3 Based on file size\n"; my $opt= ; chomp ($opt); if ($opt == 1) { print "\nEnter pattern of the file(s) to be moved to Primary Volume:"; my $pat= ; chomp ($pat); system ("ncpcon shadow $pri operation=ms pattern=$pat"); } elsif ($opt == 2) { print "\na: winthin last day\nb: 1 day to 1 week\nc: 1 week to 2 weeks\nd: 2 weeks to 1 month\ne: 1 month to 2 months\nf: 2 months to 4 months\ng: 4 months to 6 months\nh: 6 months to 1 year\ni: 1 year to 2 years\nj: More than 2 years"; my $pat= ; chomp ($pat); if ($pat =~ /^.$/ && $pat =~ /^[a-j]$/i ){ system ("ncpcon shadow $pri opeartion=ms range $pat"); } else { print "Invalid choice \n"; } } elsif ($opt == 3) { print "\na: Less than 1KB\nb: 1KB to 4KB\nc: 4KB to 16KB\nd:16KB to 64KB\ne:64KB to 256KB\nf: 256KB to 1MB\ng: 1MB to 4MB\nh:4MB to 16MB\ni:16MB to 64MB\nj:64MB to 256MB\nk:More than 64MB\n"; my $pat= ; chomp ($pat); if ($pat =~ /^.$/ && $pat =~ /^[a-k]$/i ){ system ("ncpcon shadow $pri opeartion=ms range $pat"); } else { print "Invalid choice \n"; } } else { print "Invalid choice \n"; } } elsif ($ch == 5) { print "NOTE: Data present at Primary and Shadow volume is going to remain there after the Shadow relation is removed\n"; system ("ncpcon dismount $pri"); system ("umount /media/nss/$pri"); system ("ncpcon remove shadow_volume /l $pri"); } elsif ($ch == 0) { exit (0); } else { print "Ooops......... Wrong Choice Entered!\n"; exit (0); } }