From f8806b3e14c3087915c1975df634e85b47a62f33 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 7 May 2024 20:12:20 +0200 Subject: [PATCH] remove old restic backup script and timer --- bin/restic-backup | 71 ------------------- .../systemd/user/restic-backup.service | 8 --- .../.config/systemd/user/restic-backup.timer | 10 --- 3 files changed, 89 deletions(-) delete mode 100755 bin/restic-backup delete mode 100644 restic/.config/systemd/user/restic-backup.service delete mode 100644 restic/.config/systemd/user/restic-backup.timer diff --git a/bin/restic-backup b/bin/restic-backup deleted file mode 100755 index 1e15fc5..0000000 --- a/bin/restic-backup +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash - -read_config() { - # variables - #CACHE_DIR="$HOME/.cache/restic" - #BACKUP_PATHS="/etc /home/docker/volumes /root" - #BACKUP_PATHS="/home/.snapshots/$(ls -1t /home/.snapshots | head -n 1)/snapshot/flexo" - #EXCLUDES_FILE="$HOME/.config/restic/excludes" - #KEEP_HOURS=168 - #KEEP_DAYS=60 - #KEEP_WEEKS=12 - #KEEP_MONTHS=12 - #KEEP_YEARS=3 - #RESTIC_PASSWORD="PASSWORD" - #RESTIC_REPOSITORY="sftp://foo@192.168.0.1:22//home/bar" - # or for b2 - #RESTIC_REPOSITORY="b2:backup" - #B2_ACCOUNT_ID="ID" - #B2_ACCOUNT_KEY="KEY" - - if [[ ! -f "$HOME/.config/restic/env" && ! -f "/etc/restic/env" ]]; then - echo "no config provided" - exit 1 - fi - - . $HOME/.config/restic/env 2> /dev/null || . /etc/restic/env 2> /dev/null - export RESTIC_PASSWORD="${RESTIC_PASSWORD}" -} - -info() { printf "\n\e[1m%s\e[0m\n" "$*" >&2; } - -info "Testing if restic is already running..." -if pgrep -x "restic" &> /dev/null; then - echo "-> Restic is already runnning" - exit 1 -fi -info "Done" - -info "Updating restic..." -$HOME/.local/bin/restic self-update -info "Done" - -read_config - -restic -r ${RESTIC_REPOSITORY} unlock -if [[ $1 == 'prune' ]]; then - info "Pruning snapshots..." - $HOME/.local/bin/restic --cache-dir ${CACHE_DIR} -r ${RESTIC_REPOSITORY} prune --max-unused 0 - info "Done" - - info "Checking repository..." - $HOME/.local/bin/restic -r ${RESTIC_REPOSITORY} check - info "Done" -else - if ! eval which snapper 2> /dev/null; then - # fallback - BACKUP_PATHS="/home/flexo" - fi - - info "Starting backup..." - $HOME/.local/bin/restic --cache-dir ${CACHE_DIR} -r ${RESTIC_REPOSITORY} backup ${BACKUP_PATHS} \ - --exclude-file ${EXCLUDES_FILE} - info "Done" - - info "Forgetting snapshots..." - $HOME/.local/bin/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} #--prune - info "Done" -fi diff --git a/restic/.config/systemd/user/restic-backup.service b/restic/.config/systemd/user/restic-backup.service deleted file mode 100644 index 5864066..0000000 --- a/restic/.config/systemd/user/restic-backup.service +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=restic Backup -Documentation=man:restic(1) - -[Service] -Type=simple -ExecStartPre=nm-online -ExecStart=%h/.dotfiles/bin/restic-backup diff --git a/restic/.config/systemd/user/restic-backup.timer b/restic/.config/systemd/user/restic-backup.timer deleted file mode 100644 index cfebebe..0000000 --- a/restic/.config/systemd/user/restic-backup.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=restic Backup Trigger -Documentation=man:restic(1) - -[Timer] -Persistent=true -OnCalendar=hourly - -[Install] -WantedBy=timers.target