登录 注册
数据分析与数据处理网络与基础设施安全与隐私工具 postgresql
3,481
Stars
222
Forks
33
Watchers
15
Open Issues
MIT
许可证
Ruby
语言
2015-12-08
创建时间
2026-10-29
最近更新

项目能做什么

用于在不同 Postgres 数据库之间快速同步数据的工具。
来源:基于仓库元数据 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# pgsync

Sync data from one Postgres database to another (like `pg_dump`/`pg_restore`). Designed for:

- **speed** - tables are transferred in parallel
- **security** - built-in methods to prevent sensitive data from ever leaving the server
- **flexibility** - gracefully handles schema differences, like missing columns and extra columns
- **convenience** - sync partial tables, groups of tables, and related records

:tangerine: Battle-tested at [Instacart](https://www.instacart.com/opensource)

[![Build Status](https://github.com/ankane/pgsync/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/pgsync/actions)

## Installation

pgsync is a command line tool. To install, run:

```sh
gem install pgsync
```

This will give you the `pgsync` command. If installation fails, you may need to install [dependencies](#dependencies).

You can also install it with Homebrew:

```sh
brew install pgsync
```

Or [Docker](#docker).

## Setup

In your project directory, run:

```sh
pgsync --init
```

This creates `.pgsync.yml` for you to customize. We recommend checking this into your version control (assuming it doesn’t contain sensitive information). `pgsync` commands can be run from this directory or any subdirectory.

## How to Use

First, make sure your schema is set up in both databases. We recommend using a schema migration tool for this, but pgsync also provides a few [convenience methods](#schema). Once that’s done, you’re ready to sync data.

Sync tables

```sh
pgsync
```

Sync specific tables

```sh
pgsync table1,table2
```

Works with wildcards as well

```sh
pgsync "table*"
```

Sync specific rows (existing rows are overwritten)

```sh
pgsync products "where store_id = 1"
```

You can also preserve existing rows

```sh
pgsync products "where store_id = 1" --preserve
```

Or truncate them

```sh
pgsync products "where store_id = 1" --truncate
```

## Tables

Exclude specific tables

```sh
pgsync --exclude table1,table2
```

Add to `.pgsync.yml` to exclude by default

```yml
exclude:
  - table1
  - table2
```

Sync tables from all schemas or specific schemas (by default, only the search path is synced)

```sh
pgsync --all-schemas
# or
pgsync --schemas public,other
# or
pgsync public.table1,other.table2
```

## Groups

Define groups in `.pgsync.yml`:

```yml
groups:
  group1:
    - table1
    - table2
```

And run:

```sh
pgsync group1
```

## Variables

You can also use groups to sync a specific record and associated records in other tables.

To get product `123` with its reviews, last 10 coupons, and store, use:

```yml
groups:
  product:
    products: "where id = {1}"
    reviews: "where product_id = {1}"
    coupons: "where product_id = {1} order by created_at desc limit 10"
    stores: "where id in (select store_id from products where id = {1})"
```

And run:

```sh
pgsync product:123
```

## Schema

Sync the schema before the data (this wipes out existing data)

```sh
pgsync --schema-first
```

Specify tables

```sh
pgsync table1,table
阅读完整原文

商业机会分析 规则生成(AI 未配置)

综合评分 43.6 分。该项目在“个人可实施性”维度得 45 分,“付费可能性”维度得 20.0 分,差异化空间 70.0 分(评分依据见评分卡)。

面向细分需求的二次开发产品

产品构想基于 pgsync 的核心能力,聚焦一个更窄的场景(如某平台、某行业)做差异化。
目标用户该细分场景用户
难度/周期中 · 2~6 周
收费模式买断制 / 订阅制 / 广告
竞争风险细分需求规模需验证
依据 AI 推测:基于项目主题标签的判断
以上为规则引擎基于仓库公开数据生成的参考结论,包含推测成分,不构成投资或创业承诺;配置 AI 后可获得更深入的分析。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

项目中文简介Stars语言
toluaina/pgsync 中文介绍暂未生成
Postgres, MySQL, or MariaDB to Elasticsearch/OpenSearch syn
1,434 Python
pgrundev/pgsync 中文介绍暂未生成
PGSync — Real-time PostgreSQL replication
155 Rust
kaanari-tech/fastapi-boilerplate 中文介绍暂未生成
FastAPI REST boilerplate is a comprehensive starting point f
14 Python
liashchynskyi/sync-elastic-and-postgres-docker-example 中文介绍暂未生成
Example of syncing data between PostgreSQL and ElasticSearch
12 Shell
jconway/pgsynck 中文介绍暂未生成
Run SQL text through the PostgreSQL parser and return syntax
11 C
fooklook/pgsync-studio 中文介绍暂未生成
A PostgreSQL to Elasticsearch sync platform with a web UI, c
11 Python
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。

项目优势与风险

技术成熟度创建于 2015-12-08,近 30 天仍在推送
社区活跃Star 3,481 / Fork 222 / Issue 15(数据支持,可自行核实)
许可证MIT
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

快速开始(以仓库 README 为准)
git clone https://github.com/ankane/pgsync.git
cd pgsync
docker compose up -d   # 或参考 README 中的 docker run 命令
阅读原仓库文档
术语说明:Docker=应用容器(把程序和依赖打包运行);API Key=调用外部服务的密钥;Git Clone=把仓库代码下载到本地。常见错误:API Key 未配置 / 端口占用 / 数据库连接失败,多数项目在 README 的 Troubleshooting 章节有说明。