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