Back up and restore with restic
Install restic and configure the cn-backup SSH alias. Verify the host fingerprint using SFTP before creating the repository.
Initialize onceβ
restic -r sftp:cn-backup:/data/restic init
Choose and retain the repository password. It encrypts the repository and is separate from your SSH key or portal password. Use the same password to open this repository on another computer; do not initialize it again.
Back up and inspectβ
restic -r sftp:cn-backup:/data/restic backup ./documents
restic -r sftp:cn-backup:/data/restic snapshots
restic -r sftp:cn-backup:/data/restic check
The snapshots command lists restic's own backup records. Copy a record ID when you want to restore a particular run.
Restore to a new directoryβ
restic -r sftp:cn-backup:/data/restic restore latest --target ./restic-restore
Use a record ID instead of latest to choose a specific run. Inspect the resulting folder structure and open restored files before replacing originals.
Retentionβ
Preview a policy, for example seven daily and four weekly backups:
restic -r sftp:cn-backup:/data/restic forget \
--keep-daily 7 --keep-weekly 4 --dry-run
Apply the policy without --dry-run only after reviewing it. prune reclaims unreferenced data and can take significant time and transfer. Run retention and backup jobs separately, and avoid removing repository files manually.
Scheduled useβ
Set RESTIC_REPOSITORY=sftp:cn-backup:/data/restic in your job and use RESTIC_PASSWORD_FILE pointing to a private local password file. Restrict the file's permissions to the job's user. Confirm the scheduler can access both the SSH key and repository password without prompting. See scheduling.
Restic's repository guide covers SFTP and password-file configuration.