- docker-compose.prod.yml overlay: Caddy with automatic HTTPS on one origin (web at /, API at /api incl. websocket), internal-only Postgres/ Redis/API/web, secure cookies, private-network servers blocked, nightly pg_dump backups kept 14 days - deploy/export-db.sh and import-db.sh to carry a database to the server (same TOKEN_ENCRYPTION_KEY required for stored connections) - Base compose no longer requires apps/api/.env - README: deployment, Spotify via scrobblers, SMTP settings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
21 lines
1.0 KiB
Bash
Executable File
21 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Restore a dump from export-db.sh on the server, replacing what's there.
|
|
# deploy/import-db.sh <dump-file>
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
file="${1:?usage: deploy/import-db.sh <dump-file>}"
|
|
compose=(docker compose -f docker-compose.yml -f docker-compose.prod.yml --env-file deploy/production.env)
|
|
|
|
echo "This REPLACES the server's database with $file."
|
|
read -r -p "Type 'replace' to continue: " answer
|
|
[ "$answer" = "replace" ] || { echo "Aborted."; exit 1; }
|
|
|
|
"${compose[@]}" stop api worker web
|
|
"${compose[@]}" up -d postgres
|
|
until "${compose[@]}" exec -T postgres pg_isready -U musicshare -d musicshare >/dev/null 2>&1; do sleep 1; done
|
|
"${compose[@]}" exec -T postgres pg_restore -U musicshare -d musicshare --clean --if-exists --no-owner < "$file"
|
|
# Apply any migrations newer than the dump, then bring everything back.
|
|
"${compose[@]}" run --rm migrate
|
|
"${compose[@]}" up -d
|
|
echo "Restored. Everyone needs to sign in again (sessions are per-domain), and Plex/Jellyfin webhook URLs now use the new domain."
|