From 3f0fb35573f4e2248796f83ecfbde8443babd1c8 Mon Sep 17 00:00:00 2001 From: nyanloutre Date: Sat, 11 Aug 2018 20:19:48 +0200 Subject: [PATCH] Script de sauvegarde DiskStation --- backup.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 backup.sh diff --git a/backup.sh b/backup.sh new file mode 100644 index 0000000..03aac07 --- /dev/null +++ b/backup.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Setting this, so the repo does not need to be given on the commandline: +export BORG_REPO='synology@nyanlout.re:/mnt/backup_loutre/diskstation_borg' + +# Setting this, so you won't be asked for your repository passphrase: +export BORG_PASSPHRASE='xxxxxxxxxxxxxxxxxxxxxxxxxx' + +echo "Starting backup on $BORG_REPO" + +date=$(date "+%Y-%m-%dT%H:%M:%S") +archiveName="diskstation-$date" +basePath='/volume1/Sauvegardes' + +# Backup the most important directories into an archive named after +# the machine this script is currently running on: + +borg create \ + --verbose \ + --list \ + --stats \ + --compression lz4 \ + \ + ::$archiveName \ + \ + ${basePath}/TREHIOU_THINKPAD \ + ${basePath}/PC_CLAIRE \ + ${basePath}/TREHIOU_HP + +echo "Pruning repository" + +# Use the `prune` subcommand to maintain 7 daily, 4 weekly and 6 monthly +# archives of THIS machine. The '{hostname}-' prefix is very important to +# limit prune's operation to this machine's archives and not apply to +# other machines' archives also: + +borg prune \ + --verbose \ + --prefix 'diskstation-' \ + --keep-daily 7 \ + --keep-weekly 4 \ + --keep-monthly 6 \ +