InvenTree:流式 PostgreSQL 备份
在基于 docker-compose 的 InvenTree 部署中,可按以下方式使用 pg_dump 设置流式 PostgreSQL 备份:
stream-backup.sh
source .env
docker-compose exec -T inventree-db pg_dump -U${INVENTREE_DB_USER} ${INVENTREE_DB_NAME}该命令会在 inventree-db 容器内执行 pg_dump,使用环境变量中定义的数据库凭据。-T 标志允许将输出直接流式传输到终端或主机上的文件。
与 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