Files
HomeBackup/docs/restore.md
2026-02-21 16:47:41 +01:00

3.1 KiB
Raw Permalink Blame History

Restore Runbooks

Scenario A — Full disaster recovery (SD card dead)

1. Flash a new SD card from the latest image

# On your control node — find the latest image on Synology
ls /mnt/synology-images/<hostname>/

# Flash to new SD card (replace sdX with your card device)
gunzip -c /mnt/synology-images/pi1/pi1-2025-03-01.img.gz | sudo dd of=/dev/sdX bs=4M status=progress
sync

Boot the Pi. It will come up with the OS and data as of the image date.

2. Restore data changed since the image (restic)

After the Pi is booted and on the network:

# On the Pi — restore latest snapshot to root
sudo restic restore latest --host pi1 --target /

# Or restore only specific paths
sudo restic restore latest --host pi1 --include /home --target /
sudo restic restore latest --host pi1 --include /etc --target /
sudo restic restore latest --host pi1 --include /var/lib/docker/volumes --target /

3. Restart Docker

sudo docker compose up -d   # in each compose project directory
# or
sudo systemctl start docker

Scenario B — Accidental file deletion (restic only)

# List snapshots for this host
restic snapshots --host $(hostname)

# Browse a specific snapshot
restic ls <snapshot-id> /home/pi/

# Restore a single file or directory
restic restore <snapshot-id> --include /home/pi/important-file --target /tmp/restore

# Restore to original location
restic restore <snapshot-id> --include /home/pi/important-file --target /

Scenario C — Restore OpenWrt config

The OpenWrt backup is a .tar.gz created by sysupgrade. It lives on the designated Pi at /var/backups/openwrt/ and is included in that Pi's restic backup.

From restic (Pi has been restored)

# On the receiver Pi, find the backup
ls /var/backups/openwrt/

# Copy to your workstation
scp pi@RECEIVER_HOST:/var/backups/openwrt/openwrt-2025-03-01.tar.gz .

Restore on the router

# Copy backup to router
scp openwrt-2025-03-01.tar.gz root@ROUTER_IP:/tmp/

# Restore via sysupgrade (keeps settings)
ssh root@ROUTER_IP "sysupgrade -r /tmp/openwrt-2025-03-01.tar.gz"

Scenario D — Restore a Docker volume

# Restore volume to a temp directory
restic restore latest --host pi1 \
  --include /var/lib/docker/volumes/MY_VOLUME \
  --target /tmp/restore

# Stop the container
docker compose stop SERVICE

# Replace volume data
sudo rsync -a /tmp/restore/var/lib/docker/volumes/MY_VOLUME/_data/ \
  /var/lib/docker/volumes/MY_VOLUME/_data/

# Start container
docker compose start SERVICE

Useful restic commands

# Source env (run as root on the Pi)
source /etc/restic/restic.env

# List all snapshots for this host
restic snapshots --host $(hostname)

# Show snapshot content
restic ls <snapshot-id>

# Verify repo integrity
restic check

# Show repo stats
restic stats --host $(hostname)

# Mount repo as filesystem (requires FUSE)
restic mount /mnt/restic-browse

Recovery time estimates

Scenario Approximate time
Flash SD from image (32 GB card) ~15 min
Restic restore (data-only, typical Pi) 530 min depending on changed data
OpenWrt config restore < 5 min