Commit ed293d4a authored by Simone Piccardi's avatar Simone Piccardi
Browse files

Correzioni

parent 9e105ea9
......@@ -56,9 +56,6 @@ MESS="Data dump on $(hostname) for $(date +%x)"
# all output go to TMPLOG
exec > $TMPLOG 2>&1
# define exit function (sending email)
mail_exit () {
if [ $1 != 0 ]; then
......@@ -66,19 +63,14 @@ mail_exit () {
else
MAILSUBJ="Backup ok on $(hostname) for $(date +%x)"
fi
if [ -z "$COMMAND" ]; then
if [ "$MAILTO" ]; then
DESTINARI="$MAILTO"
else
DESTINARI=root
fi
for i in $DESTINARI; do
grep -v "Hexadecimal number" $TMPLOG | mailx -s "$MAILSUBJ" $i
done
if [ "$MAILTO" ]; then
DESTINARI="$MAILTO"
else
cat $TMPLOG
echo error code $1
DESTINARI=root
fi
for i in $DESTINARI; do
grep -v "Hexadecimal number" $TMPLOG | mailx -s "$MAILSUBJ" $i
done
exit $1
}
......@@ -124,6 +116,7 @@ for i in $(df -h | egrep '([8-9][0-9]|100)\%' | awk '{print $6}'); do
echo Warning: $i at $(df -h | grep $i | awk '{print $5}');
done
}
# function to check full disks
panic_disk_full () {
FULL=$(df -h | egrep '100\%' | awk '{print $6}')
......@@ -145,7 +138,6 @@ function init_dump () {
DESTINATION=$BASEDIR/$BACKUP_DIR
[ -d $BASEDIR ] || mkdir -p $BASEDIR
umount $BASEDIR 2> /dev/null
if [ ! $DISK ]; then
echo "Deve essere definito il disco/NAS di destinazione"
......@@ -157,26 +149,33 @@ fi
##
## Command management
##
case $COMMAND in
case "$COMMAND" in
mount)
if mount $DISK $BASEDIR; then
[ -d $RECOVERDIR ] || mkdir -p $RECOVERDIR
borg mount $DESTINATION $RECOVERDIR
echo "mounted backup on $RECOVERDIR"
mail_exit 0
cat $TMPLOG
echo "mounted backup on $RECOVERDIR"
exit 0
else
cat $TMPLOG
echo "cannot mount repository"
mail_exit 6
exit 6
fi
;;
umount)
fusermount -u $RECOVERDIR
umount $DESTINATION
mail_exit 0
sleep 1
umount $BASEDIR
cat $TMPLOG
echo "backup recover umounted"
exit 0
;;
*)
echo "unknown command $COMMAND"
usage()
mail_exit 5
cat $TMPLOG
usage
exit 5
;;
esac
......@@ -279,6 +278,7 @@ fi
#
# Borg backup section
#
umount $BASEDIR 2> /dev/null
if mount $DISK $BASEDIR; then
echo "FUSS backup started at $(date +%R)"
echo "* dump su $DISK"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment