Commands
Restic & Autorestic Backup Management Guide
This guide provides step-by-step instructions for managing backups stored in Backblaze B2 using Restic and Autorestic. It covers how to check snapshots, delete snapshots, prune old backups, and other useful commands.
Install autorestic:
sudo wget -qO - https://raw.githubusercontent.com/cupcakearmy/autorestic/master/install.sh | bash
1. Checking Existing Snapshots
To list all snapshots stored in your Backblaze B2 repository, run:
restic -r b2:Macslodge:/docker-backups snapshots
Example Output:
ID Time Host Tags Paths Size
--------------------------------------------------------------------------------------------------------------------------------------------------
80d2af5c 2025-03-11 12:44:05 mac-omen ar:location:ansible_semaphore-mysql /var/lib/docker/volumes/ansible_semaphore-mysql/_data 213.160 MiB
b7ca284a 2025-03-11 12:47:44 mac-omen ar:location:ansible_semaphore-mysql /var/lib/docker/volumes/ansible_semaphore-mysql/_data 213.160 MiB
📌 Key Information:
ID
is the unique snapshot identifier.Time
is when the snapshot was taken.Paths
show the data stored in the snapshot.
To check snapshots for a specific volume:
restic -r b2:Macslodge:/docker-backups snapshots --path /var/lib/docker/volumes/ansible_semaphore-mysql/_data
2. Deleting Snapshots
To delete a specific snapshot, use its ID:
restic -r b2:Macslodge:/docker-backups forget 80d2af5c
To delete multiple snapshots:
restic -r b2:Macslodge:/docker-backups forget b7ca284a 80d2af5c
📌 Note: This removes the snapshot reference but does not free space immediately.
3. Pruning Old Backups to Free Space
After deleting snapshots, run:
restic -r b2:Macslodge:/docker-backups prune
📌 This permanently removes unreferenced data, freeing storage space in Backblaze B2.
To check available space after pruning:
restic -r b2:Macslodge:/docker-backups stats
4. Automating Backup Cleanup (Retention Policy)
Instead of manually deleting snapshots, configure Autorestic to manage them automatically. In .autorestic.yml
, add:
locations:
ansible_semaphore-mysql:
forget: prune
options:
forget:
keep-daily: 7
keep-weekly: 4
keep-monthly: 12
Then enforce the retention policy with
5. Restoring Snapshots
To restore data from a snapshot:
restic -r b2:Macslodge:/docker-backups restore 80d2af5c --target /restore/path
If the volume was deleted, recreate it first:
docker volume create ansible_semaphore-mysql
Then restore:
restic -r b2:Macslodge:/docker-backups restore 80d2af5c --target /var/lib/docker/volumes/ansible_semaphore-mysql/_data
6. Managing Repositories
Creating a New Repository
To initialize a new Restic repository in Backblaze B2:
restic -r b2:Macslodge:/docker-backups init
You will be prompted to set a repository password. Keep this password safe, as it is required for restoring data.
Deleting a Repository
To delete an entire repository and all backups:
resticDelete -rthe b2:Macslodge:/docker-backupsrepo forgetmanually --pruneis --keep-nonethe easiest way
📌 Warning: This permanently deletes all backups. Use with caution.
Editing a Repository (Changing Password)
To change the repository encryption password:
restic -r b2:Macslodge:/docker-backups change-password
7. Additional Useful Commands
Check Repository Integrity
restic -r b2:Macslodge:/docker-backups check
Verify Snapshot Integrity
restic -r b2:Macslodge:/docker-backups check --read-data
List Backup Statistics
restic -r b2:Macslodge:/docker-backups stats
Manually Run Backup
autorestic backup -a