Skip to content

Instantly share code, notes, and snippets.

@theonlydoo
Created December 8, 2023 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theonlydoo/1ee4640ffe9555dd8d3a92e67c717d00 to your computer and use it in GitHub Desktop.
Save theonlydoo/1ee4640ffe9555dd8d3a92e67c717d00 to your computer and use it in GitHub Desktop.
restic backup with auto restic, autorestic and an nfs server as a remote storage

restic.sh

#!/bin/bash
timeout 30 mount /home/backup/ && time autorestic --config /home/changeme/.autorestic.yml backup -a ; umount /home/backup

restic.service

[Unit]
Description="Restic script"

[Service]
ExecStart=/bin/bash -c "/home/changeme/restic.sh"

restic.timer

[Unit]
Description="Run restic.service 5min after boot and every 24 hours relative to activation time"

[Timer]
OnBootSec=5min
OnUnitActiveSec=24h
OnCalendar=Mon..Fri *-*-* 10:00:*
Unit=restic.service

[Install]
WantedBy=multi-user.target

/etc/fstab

storage.ip.address:/home/changeme/backup /home/backup nfs4  noauto,rw,hard,intr,rsize=8192,wsize=8192,timeo=14 0 0

~/.autorestic.yml

version: 2

locations:
  home:
    from: /home/changeme/
    to: remote
    options:
          backup:
            exclude:
              - 'Dropbox/*'
              - 'Dropbox*/*'
              - '.cache'
              - '.*CacheStorage.*'
              - '.*CachedData.*'
              - '.*Cache.*'
              - '.var/app'
              - '.cargo'
              - '.ssh'
              - '.rustup'
            exclude-file: /home/changeme/.gitignore
backends:
  remote:
    type: local
    path: "/home/backup/"
    key: "changeme"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment