1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3 # tar handler script for backupninja
5 getconf backupname `hostname --fqdn`
6 getconf backupdir /var/backups/`hostname --fqdn`
8 getconf includes "/etc /home /usr/local"
9 getconf excludes "/tmp /proc /dev /sys /net /misc /media /srv /selinux"
11 getconf TAR `which tar`
13 getconf DATE `which date`
14 getconf DATEFORMAT "%Y.%m.%d-%H%M"
16 # See if vservers are configured
17 if [ "$vservers" = "yes" ]
19 warning "vservers enabled, but tar does not support it!"
22 if [ ! -d "$backupdir" ]
24 mkdir -p "$backupdir" || fatal "Can not make directory $backupdir"
27 if [ ! -w "$backupdir" ]
29 fatal "Directory $backupdir is not writable"
32 ## DO IT #################################################
34 # here we grab a list of the packages installed and removed.
40 EXTENSION="tar.compress"
54 warning "Unknown compress filter ($tar_compress)"
63 exclude_options="$exclude_options --exclude $i"
66 debug "Running backup: " $TAR -c -p -v $compress_option $exclude_options \
67 -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
70 $TAR -c -p -v $compress_option $exclude_options \
71 -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
73 > "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.list \
74 2> "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.err
76 [ $? -ne 0 ] && fatal "Tar backup failed"