Skip to content
pgclone

pgclone

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

Overview

ID Extension Package Version Category License Language
9590
pgclone
pgclone
4.0.0
ETL
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
See Also
db_migrator
pglogical
repmgr
pgactive

preload for async/progress

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
4.0.0
18
17
16
15
14
pgclone -
RPM
PIGSTY
4.0.0
18
17
16
15
14
pgclone_$v -
DEB
PIGSTY
4.0.0
18
17
16
15
14
postgresql-$v-pgclone -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
el8.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
el9.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
el9.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
el10.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
el10.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
d12.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
d12.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
d13.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
d13.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u22.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u22.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u24.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u24.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u26.x86_64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
u26.aarch64
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
PIGSTY 4.0.0
Package Version OS ORG SIZE File URL
pgclone_18 4.0.0 el8.x86_64 pigsty 60.6 KiB pgclone_18-4.0.0-1PIGSTY.el8.x86_64.rpm
pgclone_18 4.0.0 el8.aarch64 pigsty 59.3 KiB pgclone_18-4.0.0-1PIGSTY.el8.aarch64.rpm
pgclone_18 4.0.0 el9.x86_64 pigsty 60.4 KiB pgclone_18-4.0.0-1PIGSTY.el9.x86_64.rpm
pgclone_18 4.0.0 el9.aarch64 pigsty 59.9 KiB pgclone_18-4.0.0-1PIGSTY.el9.aarch64.rpm
pgclone_18 4.0.0 el10.x86_64 pigsty 61.2 KiB pgclone_18-4.0.0-1PIGSTY.el10.x86_64.rpm
pgclone_18 4.0.0 el10.aarch64 pigsty 60.0 KiB pgclone_18-4.0.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgclone 4.0.0 d12.x86_64 pigsty 131.2 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgclone 4.0.0 d12.aarch64 pigsty 128.0 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgclone 4.0.0 d13.x86_64 pigsty 131.0 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pgclone 4.0.0 d13.aarch64 pigsty 127.5 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pgclone 4.0.0 u22.x86_64 pigsty 133.7 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pgclone 4.0.0 u22.aarch64 pigsty 133.2 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pgclone 4.0.0 u24.x86_64 pigsty 130.1 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~noble_amd64.deb
postgresql-18-pgclone 4.0.0 u24.aarch64 pigsty 129.1 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~noble_arm64.deb
postgresql-18-pgclone 4.0.0 u26.x86_64 pigsty 128.5 KiB postgresql-18-pgclone_4.0.0-1PIGSTY~resolute_amd64.deb
postgresql-18-pgclone 4.0.0 u26.aarch64 pigsty 127.9 KiB postgresql-18-pgclone_4.0.0-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.0.0, SQL install script

pgclone clones tables, schemas, functions, roles, and whole databases directly from SQL. In v4.0.0 the public API is namespaced under the pgclone schema.

Core clone functions

CREATE EXTENSION pgclone;

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.
  • 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''"}'
);

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.

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.
Last updated on