postgres-copy v1.0.0
š¤ 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
, ortarget-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. š
6 months ago