npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

postgres-copy

v1.0.0

Published

A simple CLI tool to copy the contents of a Postgres table from one database to another

Readme

📤 Postgres-Copy

A simple and developer-friendly CLI tool to copy table contents from one PostgreSQL database to another. Whether you're working across different servers or within the same instance, postgres-copy has your back. 🚀


🌟 Features

✅ Easily copy data from one Postgres table to another.
✅ Supports copying across entirely different servers.
✅ Prompts for sensitive information like passwords to keep your workflow secure.
✅ Skips user confirmation when run in non-interactive environments.


📦 Installation

Make sure you have Node.js installed. Then you can globally install postgres-copy using:

npm install -g postgres-copy

🚀 Usage

Run the CLI tool using the command:

postgres-copy [options]

Example:

postgres-copy \
  --source-url postgresql://localhost:5432/db1 \
  --source-user postgres \
  --source-table public.mytable \
  --target-url postgresql://remote-server:5432/db2 \
  --target-user admin \
  --target-password secret \
  --target-table public.mytable_copy

This will copy the table public.mytable from db1 on localhost:5432 to the table public.mytable_copy in db2 hosted on remote-server:5432.


⚙️ Available Options

| Option | Alias | Description | Type | Default | |---------------------|-------|----------------------------------------------------------------------------|---------|----------------------------------------| | --source-url | -s | The URL of the source database (e.g., postgresql://localhost:5432/mydb). | string | postgresql://localhost:5432/postgres | | --source-user | -su | The user of the source database. | string | postgres | | --source-password | -sp | The password of the source database (will be prompted if empty). | string | | | --source-table | -st | The table to copy (e.g., public.mytable). Required. | string | N/A | | --target-url | -t | The URL of the target database (defaults to source-url). | string | Source database's URL (source-url) | | --target-user | -tu | The user of the target database (defaults to source-user). | string | Source database's user (source-user) | | --target-password | -tp | The password of the target database (will be prompted if empty). | string | | | --target-table | -tt | The table to copy into (defaults to source-table). | string | Source table (source-table) | | --yes | -y | Skip confirmation prompts. | boolean | false |


💡 Handy Tips

  • Always Test Before Production: Run the command with test databases to ensure everything is being copied as expected. 💡
  • Partial Configuration: If you leave parameters like target-url, target-user, or target-table blank, the tool will reuse values from their respective source parameters.

🔧 Development

Want to contribute? Awesome! Clone the repository:

git clone https://github.com/yourusername/postgres-copy.git
cd postgres-copy
npm run build
npm install

Feel free to submit pull requests, file issues, or improve the documentation. We value community involvement! 🌈


🔒 Security

The tool will prompt for passwords if they are not provided as part of the command-line options. This avoids sensitive data being left in shell history. Always securely manage and protect access to your databases! 🔐


🌍 License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it. 😊


❤️ Acknowledgments

Big thanks to the amazing Node.js and PostgreSQL communities for their great tools and documentation that made this project possible. 💖


Enjoy using postgres-copy! If you have any feedback or ideas for improvement, let us know. 🎉