mirror of
https://0xacab.org/liberate/backupninja.git
synced 2024-11-08 20:02:32 +01:00
eabda5615c
This is probably completely unused by now, as vservers have been superseeded by alternative technology for many years already.
85 lines
2.0 KiB
Bash
85 lines
2.0 KiB
Bash
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
|
|
# vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
|
|
#
|
|
# 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"
|
|
|
|
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"
|
|
;;
|
|
"xz")
|
|
compress_option="-J"
|
|
EXTENSION="tar.xz"
|
|
;;
|
|
"zstd")
|
|
compress_option="--zstd"
|
|
EXTENSION="tar.zst"
|
|
;;
|
|
"none")
|
|
compress_option=""
|
|
;;
|
|
*)
|
|
warning "Unknown compress filter ($compress), defaulting to gzip"
|
|
compress_option="-z"
|
|
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
|
|
|
|
if [ ! $test ]; then
|
|
$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
|
|
fi
|
|
|
|
[ $? -ne 0 ] && fatal "Tar backup failed"
|
|
|
|
|
|
|