Proudly serving the GTHA

Backup guide

Restic backup reference

The core restic commands for backing up a server to S3, local disk or an SFTP/NAS destination: initialize, back up, prune old snapshots, check, list and restore.

Step 1: Initialize the repository

From the ak'tu' Consulting video series. Paths, hosts and addresses below are examples: replace them with your own. Restic is an open-source backup tool; see its documentation for the full list of options.

Run this once per destination to create the backup repository.

S3 storage

restic init -r s3:s3.amazonaws.com/bucket_name

Local storage

restic init --repo /local/path/to/repository

SFTP (NAS) storage

restic init -r sftp:user@host:/path/to/repository

Step 2: Back up the source data

Point restic at the files or directories to protect. With a password file, the command can run unattended.

S3 storage

restic backup /path/to/files/directories

Local storage

restic -r /path/to/repository --verbose backup /backup/files/directories

SFTP (NAS) storage

restic --password-file /path/.restic_passwd -r \
  sftp:backup_user@192.168.1.10:/remote/backup/path \
  --verbose backup /backup/files/directories

Step 3: Forget old snapshots

Keep a set number of daily snapshots. Add --prune to also remove the data no snapshot uses, which is what frees disk space.

S3 storage

restic forget --keep-daily 7

Local storage

restic forget --keep-daily 7 -r /path/to/repo

SFTP (NAS) storage

restic forget --keep-daily 7 --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path

List current snapshots

See which snapshots exist and when they were taken.

S3 storage

restic snapshots

Local storage

restic -r /path/to/repository snapshots

SFTP (NAS) storage

restic --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path snapshots

Validate the repository

Check that the repository is consistent. Run this regularly; a backup you have not checked is a guess.

S3 storage

restic check

Local storage

restic -r /path/to/repository check

SFTP (NAS) storage

restic --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path check

List the contents of a snapshot

Pick a snapshot ID from the snapshot list and add it to the command.

S3 storage

restic snapshots
# Select a snapshot from the list and add it to this command
restic ls --long [snapshot_id]

Local storage

restic snapshots -r /path/to/repo
# Select a snapshot from the list and add it to this command
restic ls --long [snapshot_id] -r /path/to/repo

SFTP (NAS) storage

restic --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path snapshots
# Select a snapshot from the list and add it to this command
restic ls --long [snapshot_id] --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path

Restore a snapshot

Restore everything, or just one file or directory, to a target location.

S3 storage

restic snapshots
# Select a snapshot from the list and add it to this command
restic restore [snapshot_id] --target /path/to/restore

Local storage

# Restore the entire snapshot
restic -r /path/to/repo restore [snapshot_id] --target /path/to/restore

# Restore a single file
restic -r /path/to/repo restore [snapshot_id] --target / --include /path/to/file

# Restore a directory
restic -r /path/to/repo restore [snapshot_id] --target /restore/path --include /path/to/directory

SFTP (NAS) storage

restic --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path snapshots
# Select a snapshot from the list and add it to this command
restic --password-file /path/.restic_passwd \
  -r sftp:backup_user@192.168.1.10:/remote/backup/path \
  restore [snapshot_id] --target /path/to/restore

Need backups you can rely on?

We design, monitor and test backups for businesses of all sizes, wherever you are. Book a free consultation and we will look at what you have today.

Guide revision 1.0 (September 2023), produced by ak'tu' Media Inc.

Take a copy with you

Prefer to keep this guide offline? Download the PDF version.

Free consultation

Need help putting this into practice?

We can review your setup and help you apply it safely.