#!/bin/sh -x # HOWTO restic # 1. init repository # restic -r sftp:user@host:/srv/restic-repo init # 2. backup # restic -r /srv/restic-repo --verbose backup ~/work # 3. restore # restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work # list snapshots # restic -r /srv/restic-repo snapshots # filter by path # restic -r /srv/restic-repo snapshots --path="/srv" # integry check # restic -r /srv/restic-repo check SNAPNAME="RemoteBackup-$(date +"%Y-%d-%d")-$(pwgen -A 3)" zfs list | cut -w -f1,5 | grep -v NAME | \ while read VOLUME do NAME=$(printf "$VOLUME" | cut -w -f1) MOUNTPOINT=$(printf "$VOLUME" | cut -w -f2) if [ "$MOUNTPOINT" == "none" ]; then printf "%s\n" "Volume $NAME not mounted. Not backing up." else printf "%s\n" "Creating Snapshot: $NAME@$SNAPNAME" zfs snap "$NAME@$SNAPNAME" printf "%s\n" "Transferring Snapshot: $NAME@$SNAPNAME" echo "I DO BACKUP THIS: ${MOUNTPOINT}.zfs/snapshot/$SNAPNAME/" # restic -r sftp:user@host:/backupspace backup "${MOUNTPOINT}.zfs/snapshot/$SNAPNAME" printf "%s\n" "Deleting Snapshot: $NAME@$SNAPNAME" zfs destroy "$NAME@$SNAPNAME" fi done