n8n / backup.sh
hijnu's picture
Update backup.sh
c6b42b1 verified
raw
history blame
441 Bytes
#!/bin/bash
# 使用环境变量 PGPASSWORD 进行备份
export PGPASSWORD="$DB_POSTGRESDB_PASSWORD"
# 备份数据库到固定的文件名,覆盖上一次的备份
pg_dump -U "$DB_POSTGRESDB_USER" -d "$DB_POSTGRESDB_DATABASE" -F c -b -v -f "${WORKDIR}/backups/backup.dump"
# 检查备份是否成功
if [ $? -eq 0 ]; then
echo "数据库备份成功"
else
echo "数据库备份失败"
fi
# 清理环境变量
unset PGPASSWORD