bstinson / centos / t_functional

Forked from centos/t_functional 3 years ago
Clone

Blame tests/p_amanda/amanda-server_test.sh

Christoph Galuschka 0a7f0f
#!/bin/sh
Christoph Galuschka 00442a
# Author: Christoph Galuschka <tigalch@tigalch.org>
Christoph Galuschka 0a7f0f
t_Log "Running $0 - amanda server runs a simple task (backing up /etc)"
Christoph Galuschka 0a7f0f
Christoph Galuschka aad886
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka aad886
then
Christoph Galuschka 727559
  t_Log "This is a C5 system. Skipping."
Christoph Galuschka aad886
  t_CheckExitStatus 0
Christoph Galuschka aad886
  exit $PASS
Christoph Galuschka aad886
fi
Christoph Galuschka aad886
Christoph Galuschka 0a7f0f
ret_val=0
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
# Creating necessary directories
Christoph Galuschka 0a7f0f
mkdir -p /etc/amanda/MyConfig
Christoph Galuschka 0a7f0f
mkdir -p /amanda/vtapes/slot{1,2}
Christoph Galuschka 0a7f0f
mkdir -p /amanda/holding
Christoph Galuschka 0a7f0f
mkdir -p /amanda/state/{curinfo,log,index}
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
# creating testfile in /etc
Christoph Galuschka 0a7f0f
# just some content to grep later
Christoph Galuschka 0a7f0f
STRING='This string must be found'
Christoph Galuschka 0a7f0f
echo $STRING > /etc/amandabackup-test
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
cat > /etc/amanda/MyConfig/amanda.conf <
Christoph Galuschka 0a7f0f
org "MyConfig"
Christoph Galuschka 0a7f0f
infofile "/amanda/state/curinfo"
Christoph Galuschka 0a7f0f
logdir "/amanda/state/log"
Christoph Galuschka 0a7f0f
indexdir "/amanda/state/index"
Christoph Galuschka aad886
EOF
Christoph Galuschka aad886
Christoph Galuschka 00442a
if [ $centos_ver == 5 ]
Christoph Galuschka aad886
then
Christoph Galuschka aad886
  echo 'dumpuser "amanda"' >> /etc/amanda/MyConfig/amanda.conf
Christoph Galuschka aad886
else
Christoph Galuschka aad886
  echo 'dumpuser "amandabackup"' >> /etc/amanda/MyConfig/amanda.conf
Christoph Galuschka aad886
fi
Christoph Galuschka 0a7f0f
Christoph Galuschka aad886
cat >> /etc/amanda/MyConfig/amanda.conf <
Christoph Galuschka 0a7f0f
tpchanger "chg-disk:/amanda/vtapes"
Christoph Galuschka 0a7f0f
labelstr "MyData[0-9][0-9]"
Christoph Galuschka 00442a
EOF
Christoph Galuschka 00442a
Christoph Galuschka 00442a
if [ $centos_ver -gt 6 ]
Christoph Galuschka 00442a
then
Christoph Galuschka 00442a
  echo 'autolabel "MyData%%"' >> /etc/amanda/MyConfig/amanda.conf
Christoph Galuschka 00442a
else
Christoph Galuschka 00442a
  echo 'label_new_tapes "MyData%%"' >> /etc/amanda/MyConfig/amanda.conf   
Christoph Galuschka 00442a
fi
Christoph Galuschka 00442a
Christoph Galuschka 00442a
cat >> /etc/amanda/MyConfig/amanda.conf <
Christoph Galuschka 0a7f0f
tapecycle 2
Christoph Galuschka 0a7f0f
dumpcycle 3 days
Christoph Galuschka 0a7f0f
amrecover_changer "changer"
Christoph Galuschka 0a7f0f
Christoph Galuschka aad886
tapetype TESTTAPE
Christoph Galuschka aad886
define tapetype TESTTAPE {
Christoph Galuschka 0a7f0f
  length 100 mbytes
Christoph Galuschka 0a7f0f
  filemark 4 kbytes
Christoph Galuschka 0a7f0f
}
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
define dumptype simple-gnutar-local {
Christoph Galuschka 0a7f0f
    auth "local"
Christoph Galuschka 0a7f0f
    compress none
Christoph Galuschka 0a7f0f
    program "GNUTAR"
Christoph Galuschka 0a7f0f
}
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
holdingdisk hd1 {
Christoph Galuschka 0a7f0f
    directory "/amanda/holding"
Christoph Galuschka 0a7f0f
    use 50 mbytes
Christoph Galuschka 0a7f0f
    chunksize 1 mbyte
Christoph Galuschka 0a7f0f
}
Christoph Galuschka 0a7f0f
EOF
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
echo "localhost /etc simple-gnutar-local" > /etc/amanda/MyConfig/disklist
Christoph Galuschka aad886
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka aad886
then
Christoph Galuschka aad886
  chown -R amanda /etc/amanda/MyConfig
Christoph Galuschka aad886
  chown -R amanda /amanda
Christoph Galuschka aad886
else
Christoph Galuschka aad886
  chown -R amandabackup /etc/amanda/MyConfig
Christoph Galuschka aad886
  chown -R amandabackup /amanda
Christoph Galuschka aad886
fi
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
## running amanda configuration check
Christoph Galuschka aad886
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka aad886
then
Christoph Galuschka aad886
  su amanda -c 'amcheck MyConfig' | grep -q '0 problems found'
Christoph Galuschka aad886
else
Christoph Galuschka aad886
  su amandabackup -c 'amcheck MyConfig' | grep -q '0 problems found'
Christoph Galuschka aad886
fi
Christoph Galuschka 0a7f0f
if [ $? = 1 ] 
Christoph Galuschka 0a7f0f
then
Christoph Galuschka 0a7f0f
  t_Log "amanda Configuration check failed."
Christoph Galuschka 0a7f0f
  ret_val=1
Christoph Galuschka 0a7f0f
else
Christoph Galuschka 0a7f0f
  t_Log "amanda Configuration OK."
Christoph Galuschka 0a7f0f
fi
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
## running backup of /etc
Christoph Galuschka aad886
if (t_GetPkgRel basesystem | grep -q el5)
Christoph Galuschka aad886
then
Christoph Galuschka aad886
  su amanda -c 'amdump MyConfig'  
Christoph Galuschka aad886
else
Christoph Galuschka aad886
  su amandabackup -c 'amdump MyConfig'
Christoph Galuschka aad886
fi
Christoph Galuschka aad886
Christoph Galuschka 0a7f0f
if [ $? -ne 0 ]
Christoph Galuschka 0a7f0f
then
Christoph Galuschka 0a7f0f
  t_Log "Backup job failed."
Christoph Galuschka 0a7f0f
  ret_val=1
Christoph Galuschka 0a7f0f
else
Christoph Galuschka 0a7f0f
  t_Log "Backup job successfull."
Christoph Galuschka 0a7f0f
fi
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
## checking data in backup
Rene Diepstraten 8ba8eb
grep -q "${STRING}" $(find /amanda/vtapes/ -name 00001.localhost._etc.0)
Christoph Galuschka 0a7f0f
if [ $? -ne 0 ]
Christoph Galuschka 0a7f0f
then
Christoph Galuschka 0a7f0f
  t_Log "Something is wrong with the backup - can't find content of /etc/amandabackup-test file."
Christoph Galuschka 0a7f0f
  ret_val=1
Christoph Galuschka 0a7f0f
else
Christoph Galuschka 0a7f0f
  t_Log "Backup seems OK and contains content of /etc/amandabackup-test file."
Christoph Galuschka 0a7f0f
fi
Christoph Galuschka 0a7f0f
Christoph Galuschka 0a7f0f
# cleaning up
Christoph Galuschka 0a7f0f
/bin/rm -rf /amanda
Christoph Galuschka 0a7f0f
/bin/rm -rf /etc/amanda/MyConfig
Christoph Galuschka 0a7f0f
/bin/rm -rf /etc/amandabackup-test
Christoph Galuschka 0a7f0f
Christoph Galuschka 3ff8f7
t_CheckExitStatus $ret_val
Christoph Galuschka aad886