Skip to content
pgclone

pgclone

pgclone : Clone PostgreSQL databases, schemas, tables, and functions across environments

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
9590
pgclone
pgclone
4.3.2
ETL
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
See Also
db_migrator
pglogical
repmgr
pgactive

preload for async/progress; RPM LLVM_BINPATH build fix in 2026-06-06 batch

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
4.3.2
18
17
16
15
14
pgclone-
RPM
PIGSTY
4.3.2
18
17
16
15
14
pgclone_$v-
DEB
PIGSTY
4.3.2
18
17
16
15
14
postgresql-$v-pgclone-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
el8.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
el9.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
el9.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
el10.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
el10.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
d12.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
d12.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
d13.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
d13.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u22.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u22.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u24.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u24.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u26.x86_64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
u26.aarch64
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PIGSTY 4.3.2
PackageVersionOSORGSIZEFile URL
pgclone_184.3.2el8.x86_64pigsty86.5 KiBpgclone_18-4.3.2-1PIGSTY.el8.x86_64.rpm
pgclone_184.3.2el8.aarch64pigsty84.4 KiBpgclone_18-4.3.2-1PIGSTY.el8.aarch64.rpm
pgclone_184.3.2el9.x86_64pigsty85.1 KiBpgclone_18-4.3.2-1PIGSTY.el9.x86_64.rpm
pgclone_184.3.2el9.aarch64pigsty84.8 KiBpgclone_18-4.3.2-1PIGSTY.el9.aarch64.rpm
pgclone_184.3.2el10.x86_64pigsty86.2 KiBpgclone_18-4.3.2-1PIGSTY.el10.x86_64.rpm
pgclone_184.3.2el10.aarch64pigsty84.6 KiBpgclone_18-4.3.2-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgclone4.3.2d12.x86_64pigsty198.1 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgclone4.3.2d12.aarch64pigsty193.8 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgclone4.3.2d13.x86_64pigsty198.0 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~trixie_amd64.deb
postgresql-18-pgclone4.3.2d13.aarch64pigsty192.9 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~trixie_arm64.deb
postgresql-18-pgclone4.3.2u22.x86_64pigsty199.2 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~jammy_amd64.deb
postgresql-18-pgclone4.3.2u22.aarch64pigsty198.2 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~jammy_arm64.deb
postgresql-18-pgclone4.3.2u24.x86_64pigsty194.6 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~noble_amd64.deb
postgresql-18-pgclone4.3.2u24.aarch64pigsty192.9 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~noble_arm64.deb
postgresql-18-pgclone4.3.2u26.x86_64pigsty192.4 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~resolute_amd64.deb
postgresql-18-pgclone4.3.2u26.aarch64pigsty191.2 KiBpostgresql-18-pgclone_4.3.2-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pgclone;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgclone;		# install via package name, for the active PG version

pig install pgclone -v 18;   # install for PG 18
pig install pgclone -v 17;   # install for PG 17
pig install pgclone -v 16;   # install for PG 16
pig install pgclone -v 15;   # install for PG 15
pig install pgclone -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgclone';

Create this extension with:

CREATE EXTENSION pgclone;

Usage

Source: README, Usage guide, Async guide, Release v4.3.2, changelog, SQL install script

pgclone clones tables, schemas, functions, roles, and whole databases directly from SQL. In v4.x the public API is namespaced under the pgclone schema; upstream and Pigsty currently track PostgreSQL 14-18.

Core clone functions

CREATE EXTENSION pgclone;
SELECT pgclone.version();

SELECT pgclone.table(
  'host=source-server dbname=mydb user=postgres password=secret',
  'public',
  'customers',
  true
);

SELECT pgclone.schema(
  'host=source-server dbname=mydb user=postgres password=secret',
  'sales',
  true
);

SELECT pgclone.database(
  'host=source-server dbname=mydb user=postgres password=secret',
  true
);
  • pgclone.table(...), pgclone.schema(...), pgclone.functions(...), pgclone.database(...)
  • pgclone.database_create(...) creates a local target database and clones into it.
  • _ex variants expose explicit booleans for indexes, constraints, and triggers.

Options and masking

  • JSON options support columns, where, conflict, and object toggles such as indexes, constraints, and triggers.
  • JSON options also include consistent; it defaults to cross-table consistent snapshots in v4.3.0+ and can be disabled per call with {"consistent": false}.
  • Upstream documents masking, auto-discovery of sensitive columns, static masking, dynamic masking, clone verification, and GDPR/compliance reporting in the usage guide.
SELECT pgclone.table(
  'host=source-server dbname=mydb user=postgres',
  'public', 'users', true, 'users_lite',
  '{"columns":["id","name","email"],"where":"status = ''active''"}'
);

Consistency, diff, and preflight

SELECT pgclone.diff(
  'host=source-server dbname=prod user=postgres',
  'app_schema'
)::jsonb;

SELECT pgclone.preflight(
  'host=source-server dbname=prod user=postgres',
  'app_schema'
)::jsonb;
  • pgclone.diff(conninfo, schema) reports read-only DDL drift for tables, columns, indexes, constraints, triggers, views, and sequences.
  • pgclone.preflight(conninfo, schema) checks source and target readiness before a clone, including connection, version, permission, capacity, naming-conflict, missing-role, missing-extension, and tablespace issues.
  • v4.3.0+ clones read the source under REPEATABLE READ READ ONLY by default. Multi-connection schema, database, and parallel-pool clones share one exported snapshot, preserving parent/child consistency while a live source is taking writes.
  • Long clones hold a source transaction open, which can delay vacuum cleanup and WAL recycling; use {"consistent": false} when that tradeoff matters more than cross-table consistency.

Async and progress

-- postgresql.conf
shared_preload_libraries = 'pgclone'

SELECT pgclone.schema_async(
  'host=source-server dbname=mydb user=postgres',
  'sales', true, '{"parallel":4}'
);

SELECT * FROM pgclone.jobs_view;
SELECT pgclone.progress(1);
SELECT pgclone.cancel(1);
  • pgclone.table_async(...) and pgclone.schema_async(...) run in background workers.
  • pgclone.jobs_view, pgclone.progress_detail(), pgclone.resume(), and pgclone.clear_jobs() provide job tracking and recovery.
  • v4.3.2 ports the snapshot-keeper resilience fixes to async/background-worker paths, including keepalive injection and timeout protection for networked source connections.

Caveats

  • Upstream requires PostgreSQL 14+.
  • The usage guide states the extension requires superuser privileges to install and use.
  • Async features need shared_preload_libraries = 'pgclone'; worker-pool parallelism also depends on max_worker_processes.
  • Consistent async clones may still be opted out with {"consistent": false} if a source-side snapshot issue must be bypassed.
  • Pigsty packages 4.3.2 for PostgreSQL 14-18. The June 2026 RPM rebuild used an LLVM_BINPATH build fix; reviewed upstream, no material stub delta beyond the package caveat and existing v4.3.2 async-snapshot note.
Last updated on