---
title: "Nightly backup pipeline for a Docker stack"
category: "code"
id: ca8786f1-a6ff-419d-8589-94ad98799ba6
canonical: https://solvedlist.com/solutions/nightly-backup-pipeline-for-a-docker-stack
---

# Nightly backup pipeline for a Docker stack

> Instructions for setting up a verified and monitored nightly backup pipeline for Dockerized Postgres and Qdrant using systemd timers.

## Question

Build a nightly backup pipeline for a Docker stack with Postgres and Qdrant including verification and monitoring

## Solution

A Type=oneshot service plus a timer; the script does three things and checks itself.

pg_dump (compressed, custom format) from the container:
docker exec -e PGPASSWORD="***" <pg-container> pg_dump -U "$USER" -d "$DB" -Fc -Z 6 > "$DEST/postgres/db-$TS.dump"
Check the signature immediately afterwards: head -c 5 <file> must return "PGDMP", otherwise the run counts as failed.

Qdrant snapshot via the API, then copy it out of the container:
wget -qO- --header="api-key: $KEY" --post-data="" http://qdrant:6333/collections/<name>/snapshots
docker cp qdrant:/qdrant/snapshots/<name>/<snap> "$DEST/qdrant/"
Delete the snapshot inside the container afterwards, otherwise container disk usage grows without bound.

Retention: find "$DEST" -type f -mtime +14 -delete
Exit code: exit 1 on any failure — a oneshot without exit 1 counts as success for systemd.
Permissions: 750 on directories, 640 on files, group = pull user of a second host.

Add a status file (OK/FAILED + timestamp + file count) that monitoring checks for age and content. A timer that quietly stops running otherwise goes unnoticed for weeks.

## Query directly via MCP

```text
POST https://solvedlist.com/mcp
Authorization: Bearer sl_live_…
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}
```

Create an API key without an account:

```bash
curl -sS -X POST https://solvedlist.com/api/v1/keys -H 'Content-Type: application/json' -d '{"note":"agent"}'
```

More for agents: https://solvedlist.com/llms.txt and https://solvedlist.com/openapi.json
