Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Database Tools
  3. clone_schema

clone_schema

MITPLpgSQL

A PostgreSQL utility that clones an entire schema with all its objects (tables, views, functions, etc.) using a single SQL function.

GitHubGitHub
209 stars46 forks0 contributors

What is clone_schema?

clone_schema is a PostgreSQL utility function that duplicates an entire database schema, including all its objects like tables, views, functions, and permissions, directly within the database. It solves the problem of needing to use external tools like pg_dump for schema copying, especially in restricted environments such as Amazon RDS. The tool handles complex scenarios including data transfer, DDL generation, and sequence management.

Target Audience

PostgreSQL database administrators and developers working in managed database environments like RDS, who need to quickly duplicate schemas for testing, staging, or migration purposes.

Value Proposition

Developers choose clone_schema because it operates entirely within PostgreSQL, eliminating the need for external tools or leaving the database environment. It offers a simple, single-function interface for comprehensive schema cloning with flexible options for data handling, ownership, and permissions.

Overview

Postgres clone schema utility without need of going outside of database. Makes developers life easy by running single function to clone schema with all objects. It is very handy on Postgres RDS. Utility is sponsored by http://elephas.io/

Use Cases

Best For

  • Creating staging or testing environments by duplicating production schemas
  • Migrating schemas within managed PostgreSQL services like Amazon RDS
  • Generating DDL scripts for schema objects without data
  • Quickly copying schema structures for development or experimentation
  • Handling schema duplication when external tools like pg_dump are unavailable or restricted
  • Managing schema versions by creating snapshots of current schema state

Not Ideal For

  • Projects requiring efficient cloning of very large datasets with parallel processing
  • Schemas that heavily rely on Large Objects (LOs) or foreign tables
  • Environments with complex, multiple interdependent user-defined schemas beyond the source and target
  • Teams using PostgreSQL versions below 10

Pros & Cons

Pros

Comprehensive Object Support

Clones a wide range of schema objects including tables, views, functions, types, and permissions, as detailed in the README's handled objects list.

Flexible Cloning Modes

Offers DATA, NODATA, and DDLONLY options for cloning with data, without data, or for DDL generation only, providing versatility for different use cases.

Built-in Permission Control

Includes NOOWNER and NOACL flags to customize ownership and privilege transfer, mimicking pg_dump behavior for finer control.

Sequence and Serial Integrity

Properly clones serial, identity columns, and sequences by setting correct nextval values, ensuring data consistency as described in the README.

Cons

Inefficient for Large Data

The README admits it copies tables one at a time, making it slower than pg_dump/pg_restore with parallel jobs for large datasets.

Missing Advanced Features

Does not support Large Objects (LOs) or foreign tables, limiting its usefulness for schemas that depend on these object types.

Schema Complexity Limitations

Struggles with multiple, interdependent user-defined schemas, as the README notes it only supports basic schema setups.

Open Source Alternative To

clone_schema is an open-source alternative to the following products:

EnterpriseDB Advanced Server schema cloning
EnterpriseDB Advanced Server schema cloning

EnterpriseDB Advanced Server schema cloning is a feature of EDB's PostgreSQL-based database that allows copying database schemas for testing or migration.

Frequently Asked Questions

Quick Stats

Stars209
Forks46
Contributors0
Open Issues1
Last commit16 days ago
CreatedSince 2019

Tags

#database-migration#postgresql#schema-management#postgres-extension#database-tools#data-copy#rds#ddl-generation

Built With

P
PostgreSQL

Included in

Database Tools5.1k
Auto-fetched 17 hours ago

Related Projects

Database Lab EngineDatabase Lab Engine

Instant thin cloning for PostgreSQL to scale the development process

Stars0
Forks0
Last commit
SpawnSpawn

Cloud service for creating instant database copies for development and CI. No more local db installs, instant recovery to arbitrary save points, isolated copies for each feature branch or test. Instant provisioning regardless of database size

Stars0
Forks0
Last commit
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub