File: backup-test

package info (click to toggle)
bacula 15.0.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,780 kB
  • sloc: ansic: 194,276; cpp: 41,177; sh: 28,258; python: 6,669; makefile: 5,275; perl: 3,666; sql: 1,371; java: 345; xml: 196; awk: 51; sed: 25
file content (92 lines) | stat: -rwxr-xr-x 3,216 bytes parent folder | download | duplicates (3)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash

# Copy STDOUT to FD3. This prevents the XTRACE output to be mixed
# with the normal STDOUT used for piping.
exec 3>&1

# Redirect XTRACE output to the new FD3
BASH_XTRACEFD="3"

# Activate Tracing and exit-on-error
set -ex

# Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923444
apt-get -y install debconf-utils
# If we don't reset some password fields we get a password mismatch error on
# the subsequent database reinstallation. For the purposes of this workaround
# in this isolated test environment it's easier just to reset them all.
debconf-get-selections|awk '$3=="password"{print}'|debconf-set-selections
for pkg in bacula-director-mysql bacula-director-pgsql; do
    # This test script is used in multiple cases; we want to only reinstall the
    # database if its package is installed.
    pkg_status=`dpkg-query --showformat '${db:Status-Status}' -W "$pkg" 2>/dev/null || true`
    if [ "$pkg_status" = "installed" ]; then
        echo "$pkg $pkg/dbconfig-reinstall boolean true"|debconf-set-selections
        DEBIAN_FRONTEND=noninteractive dpkg-reconfigure "$pkg"
    fi
done

echo "start testing ... "
echo "USER: ${USER}"

DBTYPE="${0##*-}"

echo "DBTYPE: ${DBTYPE}"

echo "--------- configuring Bacula daemons -----------"

FILECHGRDIR="${AUTOPKGTEST_TMP}/bacula-sd/filechgr"
RESTOREDIR="${AUTOPKGTEST_TMP}/bacula-restores"

mkdir -p "${AUTOPKGTEST_TMP}/bacula-sd/filechgr"
chown -R bacula:tape "${FILECHGRDIR}"

sed -i "s%/nonexistent/path/to/file/archive/dir%${FILECHGRDIR}%" /etc/bacula/bacula-sd.conf

sed -i "s%Where = /nonexistent/path/to/file/archive/dir/bacula-restores%Where = $RESTOREDIR%" /etc/bacula/bacula-dir.conf
sed -i "s/signature = MD5/signature = SHA1/" /etc/bacula/bacula-dir.conf
sed -i "s/signature = MD5/signature = SHA1\naclsupport = yes/" /etc/bacula/bacula-dir.conf


echo "--------- restarting services ----------- "
service bacula-director restart
service bacula-sd restart
service bacula-fd restart
sleep 10

echo "--------- checking services ----------- "
service bacula-director status
service bacula-sd status
service bacula-fd status

ps auwwwx | grep "[b]acula"

echo "----- create some file to test backup / restore ----"
BACKUP_TEST_FILE=/usr/sbin/bacula-backup.test
echo "bacula restore test" > ${BACKUP_TEST_FILE}
chown nobody:shadow ${BACKUP_TEST_FILE}
chmod 2755 ${BACKUP_TEST_FILE}

echo "---- status of all daemons ----"
echo -e "status all" | bconsole
echo
echo "---- label a volume ----"
echo -e "label volume=testvol pool=File storage=File1 drive=0 slot=0" | bconsole
echo
echo "----- create some file to test backup / restore ----"
echo "bacula restore test" > ${BACKUP_TEST_FILE}
echo
echo "------ trigger backup job -----"
echo -e "run job=BackupClient1 yes\rwait" | bconsole | grep "Job queued. JobId="
echo "status all" | bconsole
echo
echo "------ trigger restore job -----"
echo -e "restore select current\rls\rmark usr\rdone\ryes\rwait" | bconsole
echo "status all" | bconsole
grep "bacula restore test" $RESTOREDIR/${BACKUP_TEST_FILE}
echo
echo "------ compare original and restore ------"
debian/tests/scripts/diff.pl -s /usr/sbin -d ${RESTOREDIR}/usr/sbin --acl --attr
echo
echo "------ backup-test end ------"