Add scripts for backing up to NAS based on restic
This commit is contained in:
parent
5e5e489d85
commit
12683853e5
2 changed files with 31 additions and 0 deletions
24
restic-backup/.local/bin/restic-backup
Executable file
24
restic-backup/.local/bin/restic-backup
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source ~/.config/restic-backup/config.sh
|
||||
|
||||
cleanup() {
|
||||
pass gocrypt close || true > /dev/null 2>&1
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
pass gocrypt close > /dev/null 2>&1 || true
|
||||
PASS_GOCRYPT_CLOSE_TIMEOUT=2147483648 pass gocrypt open
|
||||
|
||||
for dir in ${RESTIC_BACKUP_SUBVOL_PATHS[@]}; do
|
||||
parent="$(dirname $dir)"
|
||||
snap="$parent/$(basename $dir)-restic"
|
||||
echo "snap = $snap"
|
||||
sudo btrfs subvol delete "$snap" > /dev/null 2>&1 || true
|
||||
sudo btrfs subvol snap "$dir" "$snap"
|
||||
restic-wrapper --verbose backup "$snap"
|
||||
sudo btrfs subvol delete "$snap" || true
|
||||
done
|
7
restic-backup/.local/bin/restic-wrapper
Executable file
7
restic-backup/.local/bin/restic-wrapper
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
source ~/.config/restic-backup/config.sh
|
||||
pass gocrypt open || true
|
||||
sudo restic --password-file /dev/stdin -r "$RESTIC_BACKUP_REPO" $@ <<< $(pass show "$RESTIC_BACKUP_PASS")
|
Loading…
Reference in a new issue