fixed configuration files permission check
[matthijs/upstream/backupninja.git] / handlers / tar.helper
1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2
3 HELPERS="$HELPERS tar:tar_backup"
4
5 tar_wizard() {
6    tar_title="Tar action wizard"
7
8    backupname=`hostname --fqdn`
9
10    inputBox "$tar_title" "When to run this action?" "everyday at 01"
11    [ $? = 1 ] && return
12    tar_when_run="when = $REPLY"
13
14    inputBox "$tar_title" "\"Name\" of backups" "$backupname"
15    [ $? = 1 ] && return
16    tar_backupname="backupname = $REPLY"
17    backupname="$REPLY"   
18
19    inputBox "$tar_title" "Directory where to store the backups" "/net/backups/$backupname"
20    [ $? = 1 ] && return
21    tar_backupdir="backupdir = $REPLY"
22
23    radioBox "$tar_title" "Compression" \
24        "none"     "do not filter trough" off \
25        "compress" "filter trough compress" off \
26        "gzip"     "filter trough gzip" off \
27        "bzip"     "filter trough bzip" on 
28    [ $? = 1 ] && return;    
29    result="$REPLY"
30    tar_compress="compress = $REPLY "
31
32    REPLY=
33    while [ -z "$REPLY" ]; do
34       formBegin "$tar_title: Includes"
35          formItem "Include:" /etc
36          formItem "Include:" /home
37          formItem "Include:" /usr/local
38          formItem "Include:"
39          formItem "Include:"
40          formItem "Include:"
41          formItem "Include:"
42          formItem "Include:"
43          formItem "Include:"
44          formItem "Include:"
45          formItem "Include:"
46       formDisplay
47       [ $? = 0 ] || return 1
48       tar_includes="includes = "
49       for i in $REPLY; do
50          [ -n "$i" ] && tar_includes="$tar_includes $i"
51       done
52    done
53
54    REPLY=
55    while [ -z "$REPLY" ]; do
56       formBegin "$tar_title: Excludes"
57          formItem "Exclude:" /tmp 
58          formItem "Exclude:" /proc
59          formItem "Exclude:" /sys
60          formItem "Exclude:" /dev
61          formItem "Exclude:" /srv
62          formItem "Exclude:" /media
63          formItem "Exclude:" /misc
64          formItem "Exclude:" /net
65          formItem "Exclude:" /selinux
66          formItem "Exclude:" 
67          formItem "Exclude:"
68       formDisplay
69       [ $? = 0 ] || return 1
70       tar_excludes="excludes = "
71       for i in $REPLY; do
72          [ -n "$i" ] && tar_excludes="$tar_excludes $i"
73       done
74    done
75
76 # Save the config 
77    get_next_filename $configdirectory/10.tar
78    cat > $next_filename <<EOF
79 $tar_when_run
80 $tar_backupname
81 $tar_backupdir
82 $tar_compress
83 $tar_includes
84 $tar_excludes
85
86 # tar binary - have to be GNU tar
87 #TAR=/bin/tar
88 #DATE           /bin/date
89 #DATEFORMAT     "%Y.%m.%d-%H%M"
90
91 EOF
92    chmod 600 $next_filename
93 }
94