Last change: 2025-09-25 Marcel Herrguth
As shown on https://youtu.be/P-Pr7Dy6mP8
Attribution back to this GIST is required!

Parts of this script are oriented from https://github.com/zammad/zammad/tree/develop/contrib/backup
This script supports PostGreSQL (docker) stacks only and expects your media to be in a mounted folder.

Restoration only works on a pre-installed Paperless NGX installation of the same version (or higher).
During Restore, this script will remove the existing database and stop all relevant containers.
Containers will be re-started after the restoration finished.

COMMAND REFERENCE
- backup: creates a new snapshot and backs up database and storage.
- restore <snapshot>: Restore a given snapshot from your backup. If you omit the snapshot ID, latest will be used.
- list_snapshots: List all available snapshot IDs.
- verify_health <percentage>: Verify the health of your backup repository. If you omit percentage, 100% will be assumed.