[OpenAFS] Automatic move of volumes

chas williams - CONTRACTOR chas@cmf.nrl.navy.mil
Wed, 24 Oct 2007 09:51:42 -0400

In message <1193225691.11351.34.camel@thor>,Jacob Volstrup writes:
>For quite some time I've been searching for something to help me move
>some volumes from a constantly failing /vicepa raid to my new /vicepb.
>The reason for not doing this manually is partly that I'm lazy and
>Further, I would like to have this fully automated if I would like to
>move them back in the future (perhaps when the disks for /vicepa are

i wrote this a while back when i was migrating file servers.  it takes
4 arguments, <from server> <from partition> <to server> <to partition>,
and optionally the -ro flag to also move the read-only's.

it generates a list of commands that you typically run with /bin/sh (or
you could just pipe to sh), so if you want to revert your actions at a
later save this as a script and do a little sed magic on it to reverse
the actions.

it doesnt deal with the duplicate readonly problems.  that wouldnt be
hard to add or you could just live with the errors.


eval "exec perl -S $0 $*"
        if $running_under_some_shell;

$from_server = "";
$from_partition = "";
$to_server = "";
$to_partition = "";

$do_ro = 0;

while ($_ = shift(@ARGV) )
                /^-ro$/ && (++$do_ro, last option);
                /^-/ && do {print STDERR "bad option \"$_\"\n"; last option};

			$from_server eq "" && ($from_server = $_, last end);
			$from_partition eq "" && ($from_partition = $_, last end);
			$to_server eq "" && ($to_server = $_, last end);
			$to_partition eq "" && ($to_partition = $_, last end);

open(LISTVOL, "vos listvol $from_server $from_partition|");

	($volume, $volid, $rw, $size, $k, $status) = split;

	$volid =~ /[0-9]+/ && do
		$rw eq "RW" && do
			printf "vos move %s %s %s %s %s -verbose\n",
				$from_server, $from_partition,
				$to_server, $to_partition;

		$rw eq "RO" && $do_ro && do
			$volume =~ s/\.readonly$//;

			printf "vos remsite %s %s %s\n", $from_server, $from_partition, $volume;
			printf "vos addsite %s %s %s\n", $to_server, $to_partition, $volume;
			printf "vos release %s -verbose -f\n", $volume;

exit 0;