aboutsummaryrefslogtreecommitdiff
path: root/handlers/tar
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2006-04-12 21:17:06 +0000
committerMicah Anderson <micah@riseup.net>2006-04-12 21:17:06 +0000
commitd3875324de5847b690cef19a8fd859c76dae42cd (patch)
tree567becb1b386497b769c005d420077ebe951d6b2 /handlers/tar
parentea111f2a5cb4bf2e155a2e55f119495e5c377221 (diff)
downloadbackupninja-d3875324de5847b690cef19a8fd859c76dae42cd.tar.gz
backupninja-d3875324de5847b690cef19a8fd859c76dae42cd.tar.bz2
Added tar handler
Diffstat (limited to 'handlers/tar')
-rw-r--r--handlers/tar79
1 files changed, 79 insertions, 0 deletions
diff --git a/handlers/tar b/handlers/tar
new file mode 100644
index 0000000..7f0d147
--- /dev/null
+++ b/handlers/tar
@@ -0,0 +1,79 @@
+# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
+#
+# tar handler script for backupninja
+
+getconf backupname `hostname --fqdn`
+getconf backupdir /var/backups/`hostname --fqdn`
+getconf compress bzip
+getconf includes "/etc /home /usr/local"
+getconf excludes "/tmp /proc /dev /sys /net /misc /media /srv /selinux"
+
+getconf TAR `which tar`
+getconf EXTENSION tar
+getconf DATE `which date`
+getconf DATEFORMAT "%Y.%m.%d-%H%M"
+
+# See if vservers are configured
+if [ "$vservers" = "yes" ]
+then
+ warning "vservers enabled, but tar does not support it!"
+fi
+
+if [ ! -d "$backupdir" ]
+then
+ mkdir -p "$backupdir" || fatal "Can not make directory $backupdir"
+fi
+
+if [ ! -w "$backupdir" ]
+then
+ fatal "Directory $backupdir is not writable"
+fi
+
+## DO IT #################################################
+#
+# here we grab a list of the packages installed and removed.
+#
+
+case $compress in
+ "compress")
+ compress_option="-Z"
+ EXTENSION="tar.compress"
+ ;;
+ "gzip")
+ compress_option="-z"
+ EXTENSION="tgz"
+ ;;
+ "bzip")
+ compress_option="-j"
+ EXTENSION="tar.bz2"
+ ;;
+ "none")
+ compress_option=""
+ ;;
+ *)
+ warning "Unknown compress filter ($tar_compress)"
+ compress_option=""
+ EXTENSION="tgz"
+ ;;
+esac
+
+exclude_options=""
+for i in $excludes
+do
+ exclude_options="$exclude_options --exclude $i"
+done
+
+debug "Running backup: " $TAR -c -p -v $compress_option $exclude_options \
+ -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
+ $includes
+
+$TAR -c -p -v $compress_option $exclude_options \
+ -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
+ $includes \
+ > "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.list \
+ 2> "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.err
+
+[ $? -ne 0 ] && fatal "Tar backup failed"
+
+
+