Easy Dump – A Shell Wrapper for Simplified PostgreSQL Backup and Restore
Easy Dump is a Bash‑based utility that streamlines PostgreSQL backups by wrapping pg_dump and pg_dumpall, offering multiple dump modes, parallel execution, table exclusion, automatic configuration generation, and detailed success or failure notifications for reliable database migration and maintenance.
Introduction
Easy Dump is a simple shell script that makes PostgreSQL pg_dump easier to use, providing a unified interface for dumping databases, schemas, users, and individual tables.
Dump Modes
The tool supports five dump modes (USERS, ALL, DBS, DB, TABLE) and allows options such as schema‑only dumps, parallel execution ( -L ), sleep intervals ( -t ), and user inclusion ( -u ).
Typical Usage
Generate a configuration file with:
bash pg_dump.sh -G -wDump all databases and users:
bash pg_dump.sh -M ALLDump a specific database with table exclusion and parallel dumping:
bash pg_dump.sh -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -E "public.tb_test alvin.tb_alvindb_test" -L -t 3Parallel Dump
When the -L flag is set, Easy Dump runs pg_dump for each database or table in the background, optionally sleeping between jobs with -t .
Table Exclusion
Use the -T option to exclude tables by pattern, or multiple -T options to specify several exclusions. The -E flag provides a convenient way to list tables to exclude.
Check Mode
Adding -C runs the script in check mode, validating connections and matching tables without performing any dump or restore operations.
Failure Notifications
Easy Dump sends detailed success or failure messages, including log file locations, to help administrators quickly identify and resolve issues such as authentication failures or connection problems.
Conclusion
By combining the flexibility of pg_dump with the convenience of Easy Bash, Easy Dump offers a powerful, scriptable solution for PostgreSQL backup scenarios, especially for large instances or databases with heavy tables.
Source Code
https://gitee.com/dbadaily/easybash/tree/master/easydump
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.