From 7420af2f1b09d8e169a52f1bc4e0a0286e86b2b7 Mon Sep 17 00:00:00 2001 From: Marco Kundt Date: Wed, 25 Nov 2020 16:33:45 +0100 Subject: [PATCH] Revert "moved prune to backup" This reverts commit b1926f1536fe05a18dae176ae12a796a975c9195. --- restic/.bin/restic_backup | 9 +-------- restic/.bin/restic_common | 4 ++-- restic/.bin/restic_prune | 11 +++++++++++ restic/.config/systemd/user/restic-backup.service | 2 +- restic/.config/systemd/user/restic-prune.service | 10 ++++++++++ restic/.config/systemd/user/restic-prune.timer | 10 ++++++++++ 6 files changed, 35 insertions(+), 11 deletions(-) create mode 100755 restic/.bin/restic_prune create mode 100644 restic/.config/systemd/user/restic-prune.service create mode 100644 restic/.config/systemd/user/restic-prune.timer diff --git a/restic/.bin/restic_backup b/restic/.bin/restic_backup index 2704b50..7752266 100755 --- a/restic/.bin/restic_backup +++ b/restic/.bin/restic_backup @@ -3,13 +3,6 @@ . $HOME/.bin/restic_common export RESTIC_PASSWORD="${RESTIC_PASSWORD}" -restic -r $RESTIC_REPOSITORY unlock - info "Starting backup" +restic -r $RESTIC_REPOSITORY unlock restic --cache-dir $CACHE_DIR -r $RESTIC_REPOSITORY backup $BACKUP_PATHS $BACKUP_EXCLUDES - -info "Forgetting snapshots" -restic --cache-dir $CACHE_DIR -r $RESTIC_REPOSITORY forget --keep-hourly $KEEP_HOURS --keep-daily $KEEP_DAYS --keep-weekly $KEEP_WEEKS --keep-monthly $KEEP_WEEKS --keep-yearly $KEEP_YEARS - -info "Pruning snapshots" -restic --cache-dir $CACHE_DIR -r $RESTIC_REPOSITORY prune \ No newline at end of file diff --git a/restic/.bin/restic_common b/restic/.bin/restic_common index a80bfee..0b7e7b2 100755 --- a/restic/.bin/restic_common +++ b/restic/.bin/restic_common @@ -40,7 +40,7 @@ ping -c 3 192.168.178.100 &> /dev/null if [[ $? > 0 ]]; then - ping -c 3 10.0.1.3 &> /dev/null + ping -c 3 1.1.1.1 &> /dev/null if [[ $? > 0 ]]; then info "Not connected." @@ -51,4 +51,4 @@ fi BACKUP_SERVER="192.168.178.100" echo "Done" -read_config \ No newline at end of file +read_config diff --git a/restic/.bin/restic_prune b/restic/.bin/restic_prune new file mode 100755 index 0000000..53ba722 --- /dev/null +++ b/restic/.bin/restic_prune @@ -0,0 +1,11 @@ +#!/bin/bash + +source $HOME/.bin/restic_common + +info "Forgetting snapshots" +restic -r $RESTIC_REPOSITORY unlock +restic --cache-dir $CACHE_DIR -r $RESTIC_REPOSITORY forget --keep-hourly $KEEP_HOURS --keep-daily $KEEP_DAYS --keep-weekly $KEEP_WEEKS --keep-monthly $KEEP_WEEKS --keep-yearly $KEEP_YEARS + +info "Pruning snapshots" +restic -r $RESTIC_REPOSITORY unlock +restic --cache-dir $CACHE_DIR -r $RESTIC_REPOSITORY prune diff --git a/restic/.config/systemd/user/restic-backup.service b/restic/.config/systemd/user/restic-backup.service index da20009..8c65abf 100644 --- a/restic/.config/systemd/user/restic-backup.service +++ b/restic/.config/systemd/user/restic-backup.service @@ -1,5 +1,5 @@ [Unit] -Description=restic backup +Description=borg backup Before=restic-prune.service [Service] diff --git a/restic/.config/systemd/user/restic-prune.service b/restic/.config/systemd/user/restic-prune.service new file mode 100644 index 0000000..ea3929b --- /dev/null +++ b/restic/.config/systemd/user/restic-prune.service @@ -0,0 +1,10 @@ +[Unit] +Description=prune borg snapshots +After=restic-backup.service + +[Service] +Type=oneshot +ExecStart=%h/.bin/restic_prune + +[Install] +WantedBy=multi-user.target diff --git a/restic/.config/systemd/user/restic-prune.timer b/restic/.config/systemd/user/restic-prune.timer new file mode 100644 index 0000000..e0a69cf --- /dev/null +++ b/restic/.config/systemd/user/restic-prune.timer @@ -0,0 +1,10 @@ +[Unit] +Description=prune restic snapshots + +[Timer] +Persistent=true +OnCalendar=daily +Unit=restic-prune.service + +[Install] +WantedBy=timers.target