PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/t/t10-tarball-dar-blacklist.sh

http://github.com/sukria/Backup-Manager
Shell | 86 lines | 65 code | 12 blank | 9 comment | 6 complexity | 1ebe43217fb6e2f936cc01622033eade MD5 | raw file
 1#!/bin/sh
 2
 3set -e
 4
 5
 6source testlib.sh
 7#verbose="true"
 8#warnings="true"
 9
10source confs/base.conf
11
12# taken verbatim from file attached to bug #4 that previously lived at
13# http://bugzilla.backup-manager.org/cgi-bin/attachment.cgi?id=1&action=view
14export BM_REPOSITORY_ROOT="$PWD/repository"
15export BM_ARCHIVE_METHOD="tarball"
16export BM_TARBALL_NAMEFORMAT="long"
17export BM_TARBALL_FILETYPE="dar"
18export BM_TARBALL_DUMPSYMLINKS="no"
19export BM_TARBALL_DIRECTORIES="$PWD/var/www/"
20export BM_TARBALL_BLACKLIST="$PWD/var/www/xim $PWD/var/www/Upload/ /tmp/ titi"
21source $locallib/sanitize.sh
22
23if [[ ! -x $dar ]]; then
24    info "cannot run test, need $dar"
25    exit 1
26fi
27
28# clean
29if [[ -e $PWD/var ]]; then
30    rm -rf $PWD/var
31fi        
32if [[ -e $PWD/repository ]]; then
33    rm -rf $PWD/repository
34fi    
35
36# environement
37mkdir $PWD/var
38mkdir $PWD/var/www
39mkdir $PWD/var/www/real
40mkdir $PWD/var/www/xim
41mkdir $PWD/var/www/Upload
42touch $PWD/var/www/file1
43touch $PWD/var/www/xim/file2
44touch $PWD/var/www/Upload/file3
45touch $PWD/var/www/real/file4
46
47# BM actions
48bm_init_env
49bm_init_today
50create_directories
51make_archives
52
53# test of success/failure
54name=$(get_dir_name "$PWD/var/www" "long")
55archive="$BM_ARCHIVE_PREFIX$name.$TODAY.master.1.dar"
56archive_name="$BM_ARCHIVE_PREFIX$name.$TODAY.master"
57
58if [[ -e $BM_REPOSITORY_ROOT/$archive ]]
59then
60        tempfile=$(mktemp)
61        dar -l $BM_REPOSITORY_ROOT/$archive_name > $tempfile
62        
63        if grep "xim/file2" $tempfile >/dev/null
64        then
65           warning "Archive seems to have the blacklisted dirs:"
66           if [[ "$warnings" = "true" ]]; then
67                echo "BM_TARBALL_BLACKLIST = $BM_TARBALL_BLACKLIST"
68                cat $tempfile
69           fi
70           rm -f $tempfile
71            rm -rf $PWD/repository
72            rm -rf $PWD/var
73           exit 1
74        else
75            rm -f $tempfile
76            rm -rf $PWD/repository
77            rm -rf $PWD/var
78            exit 0
79        fi                
80else
81    warning "$archive doesn't exists"
82    rm -rf $PWD/repository
83    rm -rf $PWD/var
84    exit 1
85fi    
86