Multivolume devices

If you have a big file to back-up to a remote server to which there is a multivolume tape attached, you can tar it even if your device do not change automaticaly the tape:

tar clPM –new-volume-script /root/change_tape \
–tape-length=12582912 –preserve –atime-preserve \
–rsh-command=/usr/bin/ssh -f root@backup:/dev/rmt/2n mnt/backup1

Where…

  • -c is for create
  • -l is for local
  • -P is for preserving the absolute name (or tar automaticaly strip the leading / converting all paths into relative path names)
  • -M is for multivolume
  • –preserve preserves the order and the permitions
  • –atime-preserve preserves the access times
  • –rsh-command=/usr/bin/ssh to avoid using rsh
  • -f for the file to which the back-up goes in. Here we give the user (root) at the server (backup) and the path to the device (the user must have in this machine the right to write to the device and in order to avoid futher complexity to log in the machine without giving a password)
  • –tape-length=12582912 is the length of the tape in kbytes (here is a 12G tape. For testing purposes you can give this option very short numbers to try out the script)
  • –new-volume-script you can give a relative or an absolut path, you can separate with a space or a “=” as you wish

You can use the next script for this purpose (with no guaranty at all, of course). You have to notice that this script is made for a 6 tapes multivolume device. When the 6th tape is full, you have to place new tapes in the device; no script usefull for this ;)

#!/bin/bash
export tape=`ssh root@backup “mtx -f /dev/rmt/2 status”| awk ‘/Empty/ {a= a + 1; if (a == 1) print $3}’| cut -c1`
case $tape in
6)
echo “change the tapes and tip o”
read a
ssh root@backup “mtx -f /dev/rmt/2 load 1″
echo “load 1″
ssh root@backup “mt -f /dev/rmt/2 rewind”
echo “rewind 1″
export tape=` ssh root@backup “mtx -f /dev/rmt/2 status”| awk ‘/Empty/{ a= a +1; if (a == 1) print $3}’| cut -c1`
case $tape in
1)
exit 0;;
*)
exit 1;;
esac
;;

1 | 2 | 3 | 4 | 5)
ssh root@backup “mtx -f /dev/rmt/2 unload”
echo “mtx -f /dev/rmt/2 unload”
ssh root@backup “mtx -f /dev/rmt/2 load `expr $tape + 1`”
echo “load” `expr $tape + 1`
ssh root@backup “mt -f /dev/rmt/2 rewind”
echo “rewind ” `expr $tape + 1`
export tape1=` ssh root@backup “mtx -f /dev/rmt/2 status”| awk ‘/Empty/{ a= a +1; if (a == 1) print $3}’| cut -c1`
echo “tape1 = $tape1″
echo expr $tape1 – $tape – 1
exit `expr $tape1 – $tape – 1`
;;

*)
echo “no tape! Please feed me!”;
exit 1
;;
esac

Leave a Reply

You must be logged in to post a comment.