138 lines
3.1 KiB
Markdown
138 lines
3.1 KiB
Markdown
# Restore Runbooks
|
||
|
||
## Scenario A — Full disaster recovery (SD card dead)
|
||
|
||
### 1. Flash a new SD card from the latest image
|
||
|
||
```bash
|
||
# 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:
|
||
|
||
```bash
|
||
# 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
|
||
|
||
```bash
|
||
sudo docker compose up -d # in each compose project directory
|
||
# or
|
||
sudo systemctl start docker
|
||
```
|
||
|
||
---
|
||
|
||
## Scenario B — Accidental file deletion (restic only)
|
||
|
||
```bash
|
||
# 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)
|
||
|
||
```bash
|
||
# 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
|
||
|
||
```bash
|
||
# 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
|
||
|
||
```bash
|
||
# 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
|
||
|
||
```bash
|
||
# 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) | 5–30 min depending on changed data |
|
||
| OpenWrt config restore | < 5 min |
|