InvenTree: Streaming PostgreSQL backup
In a docker-compose based InvenTree setup, here’s how to set up streaming PostgreSQL backup using pg_dump:
stream-backup.sh
source .env
docker-compose exec -T inventree-db pg_dump -U${INVENTREE_DB_USER} ${INVENTREE_DB_NAME}This command will execute pg_dump inside the inventree-db container, using the database credentials defined in your environment variables. The -T flag allows for streaming the output directly to your terminal or to a file on your host machine.
Here’s how to use it with restic:
restic-backup.sh
source .env
docker-compose exec -T inventree-db pg_dump -U${INVENTREE_DB_USER} ${INVENTREE_DB_NAME} | restic --verbose backup --stdin --stdin-filename="inventree-pgdump.sql"If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow