Skip to content

Automatically backup /home with Restic to remote server with SFTP

Notifications You must be signed in to change notification settings

bashilias/restic-systemd-files

Repository files navigation

Restic Systemd Files

This repository contains configurations files I use to backup my home directory with Restic to a remote server over SFTP. Backups are made every hour.

The systemd unit file and a systemd timer should be placed in /etc/systemd/use

  • restic-backup.service
  • restic-backup.timer

The restic configuration, exclude and password file should be placed in $HOME/.config

  • restic-backup.conf
  • restic-exclude.txt
  • restic-password.txt

Usage

  • Create user restic on your server and make sure you can login seamlessly with a SSH Key.

  • Install Restic.

  • Create a restic repository on your server.

      restic -r sftp:REMOTE-SERVER.com:/home/restic backup init
    
  • Save the password in $HOME/.config/restic-password.txt.

  • Add files and directories you want to ignore isn $HOME/.config/restic-exclude.txt.

  • Reload systemd.

      systemctl --user daemon-reload
    

ZshRC/BashRC alias

I have created two aliases in my zshrc file to make browsing the backups easier.

  • backup-snapshots - lists the restic snapshots.
  • backup-mount - mounts the snapshots in /mnt/restic-backup.
alias backup-snapshots='restic -r sftp:REMOTE-SERVER.COM:/home/restic/backup snapshots --password-file=/home/USER/.config/restic-password.txt'

alias backup-mount='sudo chmod 777 /mnt/framework-backup && restic -r sftp:REMOTE-SERVER.COM:/home/restic/backup mount /mnt/restic-backup --password-file=/home/USER/.config/resticpassword.txt'

Screenshot

About

Automatically backup /home with Restic to remote server with SFTP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published