aboutsummaryrefslogtreecommitdiff
path: root/handlers/tar.helper.in
blob: 4a483bec0b7085477ff1b0bc12d99dd61abdeee3 (plain)
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
93
94
95
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:

HELPERS="$HELPERS tar:tar_backup"

tar_wizard() {
   tar_title="Tar action wizard"

   backupname=`hostname --fqdn`

   inputBox "$tar_title" "When to run this action?" "everyday at 01"
   [ $? = 1 ] && return
   tar_when_run="when = $REPLY"

   inputBox "$tar_title" "\"Name\" of backups" "$backupname"
   [ $? = 1 ] && return
   tar_backupname="backupname = $REPLY"
   backupname="$REPLY"

   inputBox "$tar_title" "Directory where to store the backups" "/var/backups/tar/$backupname"
   [ $? = 1 ] && return
   tar_backupdir="backupdir = $REPLY"

   radioBox "$tar_title" "Compression" \
       "none"     "do not filter trough" off \
       "compress" "filter trough compress" off \
       "gzip"     "filter trough gzip" off \
       "bzip"     "filter trough bzip" on
   [ $? = 1 ] && return;
   result="$REPLY"
   tar_compress="compress = $REPLY "

   REPLY=
   while [ -z "$REPLY" ]; do
      formBegin "$tar_title: Includes"
         formItem "Include:" /etc
         formItem "Include:" /home
         formItem "Include:" /usr/local
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
         formItem "Include:"
      formDisplay
      [ $? = 0 ] || return 1
      tar_includes="includes = "
      for i in $REPLY; do
         [ -n "$i" ] && tar_includes="$tar_includes $i"
      done
   done

   REPLY=
   while [ -z "$REPLY" ]; do
      formBegin "$tar_title: Excludes"
         formItem "Exclude:" /tmp
         formItem "Exclude:" /proc
         formItem "Exclude:" /sys
         formItem "Exclude:" /dev
         formItem "Exclude:" /srv
         formItem "Exclude:" /media
         formItem "Exclude:" /misc
         formItem "Exclude:" /net
         formItem "Exclude:" /selinux
         formItem "Exclude:"
         formItem "Exclude:"
      formDisplay
      [ $? = 0 ] || return 1
      tar_excludes="excludes = "
      for i in $REPLY; do
         [ -n "$i" ] && tar_excludes="$tar_excludes $i"
      done
   done

# Save the config
   get_next_filename $configdirectory/10.tar
   cat > $next_filename <<EOF
$tar_when_run
$tar_backupname
$tar_backupdir
$tar_compress
$tar_includes
$tar_excludes

# tar binary - have to be GNU tar
#TAR=/bin/tar
#DATE           /bin/date
#DATEFORMAT     "%Y.%m.%d-%H%M"

EOF
   chmod 600 $next_filename
}