forked from zmanda/amanda
/
mkamandisk
59 lines (49 loc) · 1.54 KB
/
mkamandisk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# This script prepares an IOmega disk for use with amanda.
# More precisely, it
# - formats the disk, checking for bad sectors
# - mounts the disk and adds a data subdirectory
# - makes user amanda owner of this data sub directory
# - calls amlabel to label the disk
# - unmounts and ejects the disk.
#
# This shell script is not generally usable as is,
# because it is relying on a couple of settings of personal taste, such as
# - IOmega disks are partitioned and the fourth primary partition
# is taking the whole disk. So the disk is visible as /dev/sda4.
# - I am preferring to use an ext2 filesystem on the disk
# (rather then a dos or vfat file system)
# - I am doing a chown of the data sub directory such that - depending
# on the umask setting - only user amanda and root can see
# the files written to the disk.
# It has to be called as root
if [ "$#" -lt "2" ]
then
echo "Usage : $0 <backup set> <disk label>"
exit 1
fi
backup="$1"
label="$2"
echo "insert tape $2 into slot and press return"
read ANSWER
mkfs.ext2 -c -L $label /dev/iomega
echo "mounting disk ..."
mount /dev/iomega
if [ ! -d /mnt/iomega/lost+found ]
then
echo "mount did not work properly - please investigate"
exit 1
fi
echo "adding data subdirectory ..."
cd /mnt/iomega
mkdir data
chown -R amanda:disk .
if [ -n "$label" ]
then
echo "attempting to write amanda disk label"
su - amanda -c "/usr/sbin/amlabel $backup $label"
fi
echo "preparing to eject disk ..."
cd >/dev/null 2>&1
eject /mnt/iomega
echo "please don't forget to label with $backup $label"