sauvegardes/bin/dobackups

45 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
BINDIR=$(dirname "$0")
cd "$BINDIR"
echo "================================================================================"
echo " Sauvegardes du "$(date)
echo "================================================================================"
START_TIME=$(date +"%s")
START_SIZE=$(du -s /var/backups/borg/ | awk '{ print $1 }')
## Remount backup drive
sync
umount /var/backups
mount /var/backups
## Fix owner.
chown -R borg.borg /var/backups/borg/
## Local machine.
./dobackup-local
## Rsync machines.
./dobackup-rsync leparc.libre-en-communs.org
./dobackup-rsync fontainebleau.libre-en-communs.org
DURATION=$(($(date +"%s")-$START_TIME))
DURATION=$(printf "%02d:%02d:%02d" $((DURATION/60/60)) $((DURATION/60%60)) $((DURATION%60)))
echo "Midded at: "$(date)" Duration: $DURATION"
# Wait the end of remote Systemd timer backup (5 hours).
# Useful to have good data in report.
sleep 18000
./doreport
echo "====="
DURATION=$(($(date +"%s")-$START_TIME))
DURATION=$(printf "%02d:%02d:%02d" $((DURATION/60/60)) $((DURATION/60%60)) $((DURATION%60)))
END_SIZE=$(du -s /var/backups/borg/ | awk '{ print $1 }')
DIFF_SIZE=$(((END_SIZE-START_SIZE)/1024))
echo "Ended at: "$(date)" Duration: $DURATION Size: $DIFF_SIZE MB"
echo "================================================================================"