HomeLabDocs/db_restore.md

1.8 KiB

🧩 Database Restore Guide: Nextcloud + Immich

This guide explains how to restore database backups created by your automated scripts from compressed .sql.gz files.


What You Need

  • .sql.gz dump file (stored in /mnt/backup_nvme/db_dumps/ or /mnt/nc_data/db_dumps/)
  • Shell access to the relevant host/container
  • Database credentials (stored in Bitwarden)
  • Docker (Nextcloud) or LXC (Immich) access

🗃️ Restore Nextcloud DB (inside LXC 115)

1. Copy the desired dump file into the container

If restoring from PBS/B2:

scp nextcloud-2025-07-22.sql.gz root@192.168.1.50:/mnt/nc_data/db_dumps/

2. SSH into the Nextcloud container (LXC 115):

pct enter 115

3. Run the restore

cd /mnt/nc_data/db_dumps
gunzip nextcloud-2025-07-22.sql.gz

# Replace DB name/user as needed (see your env)
docker exec -i nextcloud-aio-database psql -U nextcloud -d nextcloud_database < nextcloud-2025-07-22.sql

🗃️ Restore Immich DB (from Proxmox04 via LXC 109)

1. Copy the dump to Proxmox04 (if pulled from B2):

rclone copy b2-pbs-encrypted:db_dumps/immich-2025-07-22.sql.gz /mnt/backup_nvme/db_dumps/

2. Run the restore from Proxmox04:

cd /mnt/backup_nvme/db_dumps
gunzip immich-2025-07-22.sql.gz

# Attach to container and restore
lxc-attach -n 109 -- runuser -u immich -- bash -c "psql -d immich < /mnt/backup_nvme/db_dumps/immich-2025-07-22.sql"

🧠 Tips

  • Always test restores in a clone or sandbox container if possible
  • After restore, confirm app behavior and log in to the web UI
  • Back up /opt/immich/.env or Docker .env for full recovery context
  • Use pg_restore instead of psql if using a binary format

Created: 2025-07-22
Maintainer: chris.darrigo@gmail.com
Stored in: Gitea (HomeLabDocs)