1.0.0 • Published 6 months ago

postgres-copy v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

šŸ“¤ 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

OptionAliasDescriptionTypeDefault
--source-url-sThe URL of the source database (e.g., postgresql://localhost:5432/mydb).stringpostgresql://localhost:5432/postgres
--source-user-suThe user of the source database.stringpostgres
--source-password-spThe password of the source database (will be prompted if empty).string
--source-table-stThe table to copy (e.g., public.mytable). Required.stringN/A
--target-url-tThe URL of the target database (defaults to source-url).stringSource database's URL (source-url)
--target-user-tuThe user of the target database (defaults to source-user).stringSource database's user (source-user)
--target-password-tpThe password of the target database (will be prompted if empty).string
--target-table-ttThe table to copy into (defaults to source-table).stringSource table (source-table)
--yes-ySkip confirmation prompts.booleanfalse

šŸ’” 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. šŸŽ‰

1.0.0

6 months ago