1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2 # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
4 # tar handler script for backupninja
6 getconf backupname `hostname --fqdn`
7 getconf backupdir /var/backups/`hostname --fqdn`
9 getconf includes "/etc /home /usr/local"
10 getconf excludes "/tmp /proc /dev /sys /net /misc /media /srv /selinux"
12 getconf TAR `which tar`
14 getconf DATE `which date`
15 getconf DATEFORMAT "%Y.%m.%d-%H%M"
17 # See if vservers are configured
18 if [ "$vservers" = "yes" ]
20 warning "vservers enabled, but tar does not support it!"
23 if [ ! -d "$backupdir" ]
25 mkdir -p "$backupdir" || fatal "Can not make directory $backupdir"
28 if [ ! -w "$backupdir" ]
30 fatal "Directory $backupdir is not writable"
33 ## DO IT #################################################
35 # here we grab a list of the packages installed and removed.
41 EXTENSION="tar.compress"
55 warning "Unknown compress filter ($tar_compress)"
64 exclude_options="$exclude_options --exclude $i"
67 debug "Running backup: " $TAR -c -p -v $compress_option $exclude_options \
68 -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
71 $TAR -c -p -v $compress_option $exclude_options \
72 -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
74 > "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.list \
75 2> "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.err
77 [ $? -ne 0 ] && fatal "Tar backup failed"