Skip to content

Instantly share code, notes, and snippets.

@stvhay
Created September 4, 2025 18:21
Show Gist options
  • Select an option

  • Save stvhay/f944b331d34767395f7bc15d8c98fadc to your computer and use it in GitHub Desktop.

Select an option

Save stvhay/f944b331d34767395f7bc15d8c98fadc to your computer and use it in GitHub Desktop.
OPNSense Restic Backup
#!/bin/sh
set -a
cd /root/restic || { >&2 echo "ERROR: Cannot change into directory."; exit 1; }
read AWS_ACCESS_KEY_ID < AWS_ACCESS_KEY_ID
read AWS_SECRET_ACCESS_KEY < AWS_SECRET_ACCESS_KEY
read RESTIC_PASSWORD < RESTIC_PASSWORD
read S3_ENDPOINT < S3_ENDPOINT
if [ ! -f /root/restic/.init ]
then
if ./restic -r s3:$S3_ENDPOINT init
then
touch .init
echo "Initialized restic repository."
fi
fi
./restic -r s3:$S3_ENDPOINT backup /usr/local/etc/config.xml
echo "Backup complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment