轩辕镜像 官方专业版
轩辕镜像
专业版
轩辕镜像 官方专业版
轩辕镜像
专业版
首页个人中心搜索镜像
交易
充值流量¥7起我的订单
文档
工具
提交工单页面收录
docker-pg-backup

danielgtmn/docker-pg-backup

danielgtmn

A modern REST API for PostgreSQL database backups to S3

下载次数: 0状态:社区镜像维护者:danielgtmn仓库类型:镜像最近更新:8 个月前
让 AI 帮你使用轩辕镜像? · 展开查看说明 · 点击收起说明

如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。

只需在 AI 对话中先发送下面这句话即可:

请先完整阅读并严格遵守以下文档中的全部规则与要求:

https://xuanyuan.cloud/agents.md

在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。

查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。

镜像简介
下载命令
镜像标签列表与下载命令
轩辕镜像,快一点,稳很多。
点击查看

PostgreSQL Backup API

https://img.shields.io/badge/docker-ready-blue.svg]([] https://img.shields.io/badge/TypeScript-007ACC?logo=typescript&logoColor=white](https://www.typescriptlang.org/) https://img.shields.io/badge/Fastify-000000?logo=fastify&logoColor=white]([]

A modern REST API for PostgreSQL database backups to S3-compatible storage (AWS S3, MinIO, DigitalOcean Spaces, etc.) with API key authentication, built with TypeScript and Fastify.

🚀 Features

  • REST API - Simple HTTP endpoints for backup operations
  • S3-Compatible Storage - Support for AWS S3 and S3-compatible services (MinIO, DigitalOcean Spaces, etc.)
  • API Key Authentication - Secure access with API key authentication
  • TypeScript - Full type safety and excellent developer experience
  • OpenAPI/Swagger - Auto-generated API documentation
  • Health Checks - Built-in health monitoring
  • Docker Ready - Production-ready containerization
  • Backup Verification - Automatic verification of successful uploads
  • Compressed Backups - Automatic gzip compression

📋 Prerequisites

  • Docker and Docker Compose
  • Node.js 18+ (for development)
  • S3-compatible storage (AWS S3, MinIO, DigitalOcean Spaces, etc.)
  • API key for authentication
  • PostgreSQL database connection details (provided per backup request)

🏃 Quick Start

  1. Clone the repository

    bash
    git clone https://github.com/danielgtmn/docker-pg-backup.git
    cd docker-pg-backup
    
  2. Configure environment

    bash
    cp env.example .env
    # Edit .env with your storage configuration
    
  3. Start the API server

    bash
    docker-compose up -d
    
  4. Access the API

    • API Base: http://localhost:3000
    • Documentation: http://localhost:3000/docs
    • Health check: http://localhost:3000/v1/api/health
    • Legacy health check: http://localhost:3000/api/health (auto-redirects)

🚀 CI/CD & Container Registry

This project uses GitHub Actions for automated CI/CD. Docker images are automatically built and published to the GitHub Container Registry (ghcr.io).

Automated Builds

  • Push to main: Triggers full CI pipeline with container build and push
  • Pull Requests: Runs tests and linting without container push
  • Version Tags: Pushing v* tags creates versioned releases

Using Published Images

bash
# Latest version from main branch
docker pull ghcr.io/danielgtmn/docker-pg-backup:latest

# Specific version
docker pull ghcr.io/danielgtmn/docker-pg-backup:v1.0.0

# Commit-based version
docker pull ghcr.io/danielgtmn/docker-pg-backup:main-<commit-sha>

Multi-Platform Support

Images are built for both linux/amd64 and linux/arm64 architectures.

🔧 Configuration

Create a .env file based on env.example:

bash
# API Configuration
NODE_ENV=production
PORT=3000
HOST=0.0.0.0

# API Authentication (required)
API_KEY=your-secure-api-key-here

# PostgreSQL Connection String (optional - provided per backup request)
# DATABASE_URL=postgresql://username:password@hostname:port/database

# ================= AWS S3 Storage =================
S3_BUCKET=my-backup-bucket
S3_PREFIX=postgres-backups
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key

# ================= MinIO / Custom S3 =================
# S3_ENDPOINT=https://minio.example.com:9000
# S3_BUCKET=my-backup-bucket
# S3_PREFIX=postgres-backups
# AWS_ACCESS_KEY_ID=minio-access-key
# AWS_SECRET_ACCESS_KEY=minio-secret-key

# ================= DigitalOcean Spaces =================
# S3_ENDPOINT=https://fra1.digitaloceanspaces.com
# S3_BUCKET=my-spaces-bucket
# S3_PREFIX=postgres-backups
# AWS_REGION=fra1
# AWS_ACCESS_KEY_ID=spaces-access-key
# AWS_SECRET_ACCESS_KEY=spaces-secret-key

☁️ S3-Compatible Storage Support

This API supports various S3-compatible storage services:

AWS S3 (Standard)

bash
S3_ENDPOINT=               # (optional, uses AWS default)
S3_BUCKET=my-bucket
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...

MinIO (Self-hosted S3)

bash
S3_ENDPOINT=https://minio.example.com:9000
S3_BUCKET=my-bucket
AWS_ACCESS_KEY_ID=minio-user
AWS_SECRET_ACCESS_KEY=minio-password

DigitalOcean Spaces

bash
S3_ENDPOINT=https://fra1.digitaloceanspaces.com
S3_BUCKET=my-spaces-bucket
AWS_REGION=fra1
AWS_ACCESS_KEY_ID=spaces-key
AWS_SECRET_ACCESS_KEY=spaces-secret

Other S3-compatible services

  • Linode Object Storage: S3_ENDPOINT=https://us-east-1.linodeobjects.com
  • Wasabi: S3_ENDPOINT=https://s3.wasabisys.com
  • Backblaze B2: S3_ENDPOINT=https://s3.us-west-002.backblazeb2.com

📡 API Versioning

This API uses semantic versioning for all endpoints to ensure backward compatibility and smooth upgrades.

Version Strategy

  • Current Version: v1 (stable)
  • Version Format: /v{number}/api/{endpoint}
  • Backward Compatibility: Legacy /api/* routes are automatically redirected to /v1/api/*
  • Deprecation Policy: Older versions are supported for 12 months after new version release

Supported API Versions

VersionStatusRelease DateDeprecation DateSunset Date
v1Current2024-01-01--

Versioned API Endpoints

Note: All API endpoints require authentication via API key in the Authorization header.

Version 1 (Current)

http
# Create Backup
POST /v1/api/backup
Authorization: Bearer your-api-key-here
Content-Type: application/json

{
  "databaseUrl": "postgresql://user:pass@host:5432/mydb",
  "backupName": "my-backup.sql.gz"  // optional
}

# List Backups
GET /v1/api/backups?limit=10&prefix=my-backups

# Health Check
GET /v1/api/health

# Configuration Info
GET /v1/api/config

Legacy Compatibility (Automatic Redirect)

The following legacy routes are automatically redirected to versioned endpoints:

  • /api/backup → /v1/api/backup
  • /api/backups → /v1/api/backups
  • /api/health → /v1/api/health
  • /api/config → /v1/api/config

📋 Interactive API Documentation

Visit http://localhost:3000/docs for the complete interactive Swagger documentation with:

  • ✅ Detailed request/response schemas
  • ✅ Schema validation details
  • ✅ Try-it-out functionality
  • ✅ Authentication setup
  • ✅ Version-specific documentation

Migration Guidelines

Upgrading from Legacy API

If you're currently using the legacy /api/* endpoints:

  1. No immediate action required - Legacy routes still work via automatic redirects
  2. Update your clients to use versioned endpoints (/v1/api/*) for better performance
  3. Test your integration with versioned endpoints in a staging environment
  4. Update your client code to use the new endpoints before legacy deprecation

Example Migration

Before (Legacy):

bash
curl -X POST http://localhost:3000/api/backup \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"databaseUrl": "postgresql://..."}'

After (Versioned):

bash
curl -X POST http://localhost:3000/v1/api/backup \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"databaseUrl": "postgresql://..."}'

Deprecation and Sunset Policy

  1. New Version Release: When a new API version is released, the previous version enters "deprecated" status
  2. Deprecation Period: Deprecated versions are supported for 12 months with full functionality
  3. Sunset Date: After 12 months, deprecated versions are removed from the API
  4. Communication: Version changes are communicated via:
    • GitHub release notes
    • API response headers (X-API-Version, X-Deprecation-Warning)
    • Updated documentation

Version Headers

API responses include version information in headers:

http
X-API-Version: v1
X-API-Current-Version: v1
X-API-Supported-Versions: v1

Deprecated endpoints include additional headers:

http
X-Deprecation-Warning: "API version v1 is deprecated. Please migrate to v2"
X-Sunset-Date: "2025-01-01T00:00:00Z"

Required headers:

  • Authorization: Bearer <your-api-key>
  • Content-Type: application/json

Required fields:

  • databaseUrl: PostgreSQL connection string (must start with postgresql://)

Optional fields:

  • backupName: Custom backup filename (defaults to timestamp)

Response:

json
{
  "success": true,
  "data": {
    "backupPath": "s3://my-backup-bucket/postgres-backups/20241201_120000_backup.sql.gz",
    "fileSize": 1048576,
    "duration": 2500,
    "timestamp": "2024-12-01T12:00:00.000Z"
  }
}

List Backups

Versioned Endpoint (Recommended)

http
GET /v1/api/backups?limit=10&prefix=my-backups

Legacy Endpoint (Auto-redirects to versioned)

http
GET /api/backups?limit=10&prefix=my-backups

Health Check

Versioned Endpoint (Recommended)

http
GET /v1/api/health

Legacy Endpoint (Auto-redirects to versioned)

http
GET /api/health

Configuration Info

Versioned Endpoint (Recommended)

http
GET /v1/api/config
Authorization: Bearer your-api-key-here

Legacy Endpoint (Auto-redirects to versioned)

http
GET /api/config
Authorization: Bearer your-api-key-here

🐳 Docker Usage

Development

bash
# Build and run
docker-compose up --build

# Run in background
docker-compose up -d

# View logs
docker-compose logs -f postgres-backup-api

# Stop
docker-compose down

Production

bash
# Build for production
docker build -t postgres-backup-api .

# Run with .env file (recommended)
docker run -d \
  --name postgres-backup-api \
  --env-file .env \
  -p 3000:3000 \
  postgres-backup-api

# Or run with manual environment variables
docker run -d \
  --name postgres-backup-api \
  -p 3000:3000 \
  -e S3_BUCKET="my-bucket" \
  -e AWS_ACCESS_KEY_ID="..." \
  -e AWS_SECRET_ACCESS_KEY="..." \
  -e API_KEY="your-secure-api-key" \
  postgres-backup-api

🔒 Security

  • Environment Variables - Never commit sensitive credentials
  • Non-root Container - Runs as limited user
  • CORS Configured - Properly configu***-origin requests
  • Input Validation - Zod schema validation for all inputs
  • Error Handling - Graceful error responses without information leakage

🏗️ Development

bash
# Install dependencies
pnpm install

# Development mode with hot reload
pnpm dev

# Build for production
pnpm build

# Run tests
pnpm test

# Lint code
pnpm lint

📚 API Documentation

When running, visit http://localhost:3000/docs for interactive API documentation with:

  • Request/response schemas
  • Example requests
  • Authentication details
  • Error codes

🔧 Supported Storage Backends

StorageConfigurationVerificationNotes
AWS S3S3_BUCKET, AWS_ACCESS_KEY_ID✅ HeadObjectMost common choice
Google Cloud StorageGCS_BUCKET, GOOGLE_APPLICATION_CREDENTIALS✅ File existsRequires service account
Azure Blob StorageAZURE_ACCOUNT, AZURE_CONTAINER✅ Blob existsRequires storage account
Local FilesystemBACKUP_DIR✅ File existsFor development/testing

🚨 Error Handling

The API returns structured error responses:

json
{
  "success": false,
  "error": "Validation failed",
  "details": ["databaseUrl is required"]
}

Common HTTP status codes:

  • 200 - Success
  • 400 - Bad Request (validation errors)
  • 500 - Internal Server Error

📊 Monitoring

  • Health check endpoint at /v1/api/health (versioned) or /api/health (legacy, auto-redirects)
  • Detailed logging in container logs
  • Docker health checks configured
  • API metrics available in logs
  • Version information included in response headers

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if needed
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

镜像拉取方式

您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

轩辕镜像加速拉取命令点我查看更多 docker-pg-backup 镜像标签

docker pull docker.xuanyuan.run/danielgtmn/docker-pg-backup:<标签>

使用方法:

  • 登录认证方式
  • 免认证方式

DockerHub 原生拉取命令

docker pull danielgtmn/docker-pg-backup:<标签>

轩辕镜像配置手册

按平台快速找到配置文档

一键安装

一键安装 Docker

Linux Docker 一键安装

AI

用 AI 使用轩辕镜像

agents.md · AI 对话 · 提示词

Docker

登录仓库拉取

登录认证 · 私有仓库

专属域名拉取

免登录 · 高速拉取

Linux

Docker 镜像配置

Windows / Mac

Docker Desktop 配置

MacOS OrbStack

OrbStack 容器

Apple Container

macOS 原生容器

Docker Compose

Compose 项目配置

NAS

群晖

Synology 配置

飞牛

fnOS 镜像配置

绿联

绿联 NAS

威联通

QNAP 配置

极空间

极空间 NAS

Unraid

Unraid NAS

企业仓库

其他仓库

ghcr · Quay · nvcr

Harbor 镜像源

Proxy Repository 对接

Portainer 镜像源

Registries 配置

Nexus 镜像源

Docker Proxy 缓存

开发工具

Dev Containers

VS Code 开发容器

Podman

Podman 配置指南

Singularity / Apptainer

HPC 科学计算容器

Kubernetes

K8s Containerd

Kubernetes · Containerd

K3s

轻量级集群

面板 / 网络

爱快路由

iKuai 镜像加速

宝塔面板

一键配置镜像源

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

功能

版本功能对比

功能对比 · 版本选择

支持的镜像仓库

Docker Hub · GCR · GHCR

新手拉取配置

登录 · 专属域名 · 配置

docker search 限制

专属域名 · Hub 搜索

不支持 push

仅支持 pull · 不支持

拉取速度原因

带宽 · 缓存 · 冷热镜像

错误码

402 与流量用尽

402 · 流量包 · 充值

401 认证失败

401 · docker login

manifest unknown

标签错误 · 镜像不存在

410 Gone 排查

410 · Docker 升级

429 限流

免费版 · 专业版 · 企业版 · 请求频率

其他报错

DNS 超时

DNS 解析 · 网络超时

TLS 证书失败

no matching manifest(架构)

账号

失败是否计费

manifest · blob · 计费

申请开发票(企业 / 个人)

企业 · 个人 · 工单

修改登录密码

网站 · 仓库 · 重置

注销账户

工单 · 数据 · 注销

原理

mirrors 不生效

daemon.json · 重启

去掉域名前缀

docker tag · 重命名

指定架构拉取

ARM64 · AMD64 · 多架构

latest 与「最新」

digest · 版本号 · 标签

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
danielgtmn/docker-pg-backup
教程轩辕镜像功能与使用教程
定价查看流量套餐与价格
热门查看热门 Docker 镜像推荐
博客Docker 镜像公告与技术博客
专业版 · 高速稳定拉取镜像
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
50GB 仅 ¥7/年
专业版 · 高速稳定拉取镜像
50GB 仅 ¥7/年
高速镜像下载·在线技术支持·99.95% SLA 保障·付费会员免广告
用户协议·隐私政策·增值电信业务经营许可证:浙B2-20261007·©2024-2026 源码跳动©2024-2026 杭州源码跳动科技有限公司·商务合作:点击复制邮箱

更多 docker-pg-backup 镜像推荐

fairpoker/docker-pg-backup logo

fairpoker/docker-pg-backup

fairpoker
Daily postgres data backups
848 次下载
6 年前更新
hedmade/docker-pg-backup logo

hedmade/docker-pg-backup

hedmade
a docker container to backup postgres db
553 次下载
6 年前更新
docker/dockerfile logo

docker/dockerfile

Docker 官方工具与组件镜像
这些是官方提供的Dockerfile前端镜像,主要功能是支持通过BuildKit构建Dockerfile,作为构建流程中的关键前端工具,能够有效配合BuildKit提升Dockerfile的构建效率、安全性与灵活性,为开发者提供官方认可的标准化构建方案,适用于各类基于Docker的应用开发与部署场景,确保构建过程的稳定可靠及操作便捷性。
128 次收藏5亿+ 次下载
17 天前更新
docker/dockerfile-copy logo

docker/dockerfile-copy

Docker 官方工具与组件镜像
此Docker镜像已被弃用。
1 次收藏5000万+ 次下载
7 年前更新
docker/docker-model-backend-llamacpp logo

docker/docker-model-backend-llamacpp

Docker 官方工具与组件镜像
暂无描述
2 次收藏5000万+ 次下载
23 天前更新
docker/volumes-backup-extension logo

docker/volumes-backup-extension

Docker 官方工具与组件镜像
暂无描述
4 次收藏10万+ 次下载
1 年前更新

查看更多 docker-pg-backup 相关镜像