Restic is a fast, secure, and efficient backup program that supports deduplication, encryption, and data integrity verification.

Using Restic:

  1. Installation: Install restic on your system, see restic installation

    apt install restic
  2. Initialization: Initialize a new repository for your backups.

    restic init --repo /path/to/repository --password-file ~/.restic.pass
  3. Backup: Back up files or directories to the repository.

    restic --repo /path/to/repository backup /path/to/data
  4. Listing Backups: List snapshots of the repository.

    restic --repo /path/to/repository snapshots
    restic --repo /path/to/repository snapshots --group-by host
  5. Restoring: Restore files or directories from a backup.

    restic --repo /path/to/repository restore latest --target /path/to/restore
  6. Purging Old Snapshots: Remove old snapshots from the repository.

    restic --repo /path/to/repository forget --keep-last 5 --prune
  7. Mounting Snapshots: Mount a snapshot to a directory for browsing.

    restic --repo /path/to/repository mount /path/to/mount
    
  8. Backing Up Remotely: Back up to a remote repository over SSH.

    restic --repo sftp:user@server:/path/to/repository backup /path/to/data
  9. Automating Backups: Use cron or systemd timers to schedule regular backups.

    0 2 * * * restic --repo /path/to/repository backup /path/to/data
  10. Checking Repository Stats: To check disk usage (raw deduplicated or restore size).

    restic -r /path/to/repository stats --mode raw-data
    restic -r /path/to/repository stats --mode restore-size #default, can also specify --host hostname or --path /home/user
  11. Utilizing ENV Vars to Store Encryption Keys: Note, you can ommit all --repo flags in the above commands and store your secrets by utilizing env vars. For instance you can create an env file as below and then source it prior to running any restic commands: ( source ~/.restic-env )

    export B2_ACCOUNT_ID="your-b2-account-id"
    export B2_ACCOUNT_KEY="your-b2-account/key"
    export RESTIC_REPOSITORY="b2:my-restic-backup"
    export RESTIC_PASSWORD_FILE="/root/.restic-password"

Next Post Previous Post