pg_dump 的十六般变化
作者介绍
李振中
2020年8月加入去哪儿旅行,主要负责公司 PostgreSQL 和 Oracle 的运维管理工作。
Easy Dump
While you are upgrading from PostgreSQL earlier releases like PostgreSQL 9.1 to later releases like PostgreSQL 11, pg_dumpandpg_upgrade provided by PostgreSQL are the most reliable and most powerful tools.
pg_dump is more flexible and can also be used to dump some of databases or tables to another instance.
Easy Dump is a simple shell script to make PostgreSQL pg_dump easier.
With Easy Dump, you are able to dump databases or tables into another PostgreSQL instance easily in one command line.
Apart from the dump functionality, Easy Dump also sends successful notifications and checks errors when dump or restore failed and sends failure notifications with details in cases like invalid password is given or no proper ACL is given, so that you are informed timely with helpful information.
Easy Dump introduction
Easy Dump Overview
Easy Dump is written with library Easy Bash[1] and provides 5 dump modes to support 16 most useful cases.
Why use Easy Bash
Easy Bash is a simple bash library to make scripting easier.
With Easy Bash, you are able to parse command line parameters with only one line(15 characters):
parse_args "$@"In fact, there is much more Easy Bash can do.
Easy Bash helps you write simple, efficient and colorful scripts easily.
You no longer need to do the following manually:
1. parse all the arguments manually
2. set variables manually
3. write help message manually
4. write config file manually
5. check whether all required parameters are set manually
6. send messages easily
Easy Bash Overview
Example data
Source PostgreSQL instance
Create user
CREATE USER alvin WITH PASSWORD 'alvin';Create databases and tables
Database alvindb
CREATE DATABASE alvindb OWNER alvin;\c alvindbCREATE SCHEMA alvin AUTHORIZATION alvin;
Create tables.
\c alvindb alvinCREATE TABLE tb_alvindb_vacuum (test_id BIGSERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_alvindb_sequence (test_id SERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_alvindb_test (test_id SERIAL PRIMARY KEY,test_num BIGINT);INSERT INTO tb_alvindb_vacuum(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_alvindb_sequence(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_alvindb_test(test_num) SELECT gid FROM generate_series(1,3,1) gid;
Database dbadaily
CREATE DATABASE dbadaily OWNER alvin;Create tables.
\c alvindb alvinCREATE TABLE tb_alvindb_vacuum (test_id BIGSERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_alvindb_sequence (test_id SERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_alvindb_test (test_id SERIAL PRIMARY KEY,test_num BIGINT);INSERT INTO tb_alvindb_vacuum(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_alvindb_sequence(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_alvindb_test(test_num) SELECT gid FROM generate_series(1,3,1) gid;
Database testdb
CREATE DATABASE testdb OWNER alvin;Create tables.
\c testdb alvinCREATE TABLE tb_testdb_vacuum (test_id BIGSERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_testdb_sequence (test_id SERIAL PRIMARY KEY,test_num BIGINT);CREATE TABLE tb_testdb_test (test_id SERIAL PRIMARY KEY,test_num BIGINT);INSERT INTO tb_testdb_vacuum(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_testdb_sequence(test_num) SELECT gid FROM generate_series(1,3,1) gid;INSERT INTO tb_testdb_test(test_num) SELECT gid FROM generate_series(1,3,1) gid;
Target PostgreSQL instance
Dump options
add_main_options() {## custom options# source dbadd_options "h:" "host:" "DBHOST" "Y" "source database server host or socket directory"add_options "p:" "port:" "DBPORT" "Y" "source database server port number"add_options "U:" "username:" "DBUSER" "Y" "source database user name"add_options "W:" "password:" "PGPASSWORD" "Y" "source database user password"add_options "d:" "dbname:" "DBNAME" "N" "source database name to connect to"# target dbadd_options "P:" "target-port:" "DBPORT_TARGET" "Y" "target database server port number"add_options "B:" "bin-dir:" "PGBIN" "Y" "PostgreSQL bin directory"# dump modesadd_options "M:" "mode:" "DUMP_MODE" "Y" "dump modes: ALL USERS DBS DB TABLE"# ALL modeadd_options "s" "schema-only" "SCHEMA_ONLY" "N" "SCHEMA mode: dump only the schema, no data"# ALL or DBS modeadd_options "D:" "databases:" "DATABASES" "N" "ALL mode: databases(separated by space) to dump"# DB or TABLE modeadd_options "T:" "tables:" "DBTABLES" "N" "tables(separated by space) to dump. DB mode: dump tables in parallel; TABLE mode: tables to dump"# DB modeadd_options "E:" "excludetables:" "DBTABLES_EXCLUDE" "N" "tables to exclude"# other optionsadd_options "u" "users" "DUMP_ALL_USERS" "N" "dump all users regardless of dump mode"add_options "L" "parallel" "PARALLEL_IND" "N" "parallel indicator"add_options "t:" "sleep-time:" "SLEEP_TIME" "N" "time to sleep between dumps"### common options## 1. options like m: or emails: can be changed## 2. variable names like RECIPIENTS are NOT expected to be changed as they are used in shared functionsadd_options "m:" "email:" "RECIPIENTS" "N" "emails(separated by space) to receive notifications"add_options "S" "success-notification" "SUCCESS_NOTIFICATION_IND" "N" "indication whether to send success notifications"add_options "C" "check" "CHECK_MODE" "N" "don't make any changes"add_options "G" "generate-config" "GEN_CONFIG" "N" "generate config file if not exists"add_options "w" "write-values" "WRITE_VALUES" "N" "used together with -G, write values provided by command options to config file"add_options "H" "help" "HELP" "N" "show this help"add_options "V" "version" "VERSION" "N" "output version information"add_options "v" "verbose" "VERBOSE" "N" "verbose mode"}
$ bash pg_dump.sh -HVersion: 1.0.0Usage:bash pg_dump.sh [OPTIONS]OPTIONS:-h, --host="DBHOST" Required source database server host or socket directory-p, --port="DBPORT" Required source database server port number-U, --username="DBUSER" Required source database user name-W, --password="PGPASSWORD" Required source database user password-d, --dbname="DBNAME" Optional source database name to connect to-P, --target-port="DBPORT_TARGET" Required target database server port number-B, --bin-dir="PGBIN" Required PostgreSQL bin directory-M, --mode="DUMP_MODE" Required dump modes: ALL USERS DBS DB TABLE-s, --schema-only Optional SCHEMA mode: dump only the schema, no data-D, --databases="DATABASES" Optional ALL mode: databases(separated by space) to dump-T, --tables="DBTABLES" Optional tables(separated by space) to dump. DB mode: dump tables in parallel; TABLE mode: tables to dump-E, --excludetables="DBTABLES_EXCLUDE" Optional tables to exclude-u, --users Optional dump all users regardless of dump mode-L, --parallel Optional parallel indicator-t, --sleep-time="SLEEP_TIME" Optional time to sleep between dumps-m, --email="RECIPIENTS" Optional emails(separated by space) to receive notifications-S, --success-notification Optional indication whether to send success notifications-C, --check Optional don't make any changes-G, --generate-config Optional generate config file if not exists-w, --write-values Optional used together with -G, write values provided by command options to config file-H, --help Optional show this help-V, --version Optional output version information-v, --verbose Optional verbose mode
Generate config file
-G and -w to generate a config file and write static variables into the config file, so that only a few options need to be provided by command line.bash pg_dump.sh -h alvindb1.dbadaily.com -p 5432 -U postgres -P 5432 -B "/usr/pg11/bin/" -m "alvin@dbadaily.com" -W postgres -S -G -w[2022-05-15 20:54:09 INFO] [parse_args] config file generated with values: /data/scripts/easybash/easydump/config.shAfter config file generated, command
bash pg_dump.sh -v -M USERSis equivalent to
bash pg_dump.sh -h alvindb1.dbadaily.com -p 5432 -U postgres -P 5432 -B "/usr/pg11/bin/" -m "alvin@dbadaily.com" -W postgres -S -v -M USERSCheck the config file.
$ cat /data/scripts/easybash/easydump/config.sh# source database server host or socket directoryexport DBHOST="alvindb1.dbadaily.com"# source database server port numberexport DBPORT="5432"# source database user nameexport DBUSER="postgres"# source database user passwordexport PGPASSWORD="postgres"# source database name to connect toexport DBNAME=""# target database server port numberexport DBPORT_TARGET="5432"# PostgreSQL bin directoryexport PGBIN="/usr/pg11/bin/"# dump modes: ALL USERS DBS DB TABLEexport DUMP_MODE=""# SCHEMA mode: dump only the schema, no dataexport SCHEMA_ONLY=""# ALL mode: databases(separated by space) to dumpexport DATABASES=""# tables(separated by space) to dump. DB mode: dump tables in parallel; TABLE mode: tables to dumpexport DBTABLES=""# tables to excludeexport DBTABLES_EXCLUDE=""# dump all users regardless of dump modeexport DUMP_ALL_USERS=""# parallel indicatorexport PARALLEL_IND=""# time to sleep between dumpsexport SLEEP_TIME=""# emails(separated by space) to receive notificationsexport RECIPIENTS="[email protected]"# indication whether to send success notificationsexport SUCCESS_NOTIFICATION_IND="Y"# don't make any changesexport CHECK_MODE=""
Dump modes
USERS
Dump roles only
2. Not all passwords are same between the old instance and the new instance, such as the replicator password
PostgreSQL pg_dump command
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -g 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M USERS[2022-05-15 21:02:36 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210236.log[2022-05-15 21:02:36 TRACE] [parse_args] lv_valid_args: ' -v -M 'USERS' --'[2022-05-15 21:02:36 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:02:36 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:02:36 DEBUG] [parse_args] DUMP_MODE=USERS[2022-05-15 21:02:36 INFO] DUMP_MODE=USERS PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:02:36 TRACE] lv_case='USERS case 1 - Dump roles only'[2022-05-15 21:02:36 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210236_dumpall.log[2022-05-15 21:02:36 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210236_restore.log[2022-05-15 21:02:36 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:02:36 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: USERS case 1 - Dump roles only. Users dumped.
ALL
Dump all schema only
PostgreSQL pg_dump command
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -s 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M ALL -s[2022-05-15 20:54:58 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205458.log[2022-05-15 20:54:58 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -s --'[2022-05-15 20:54:58 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 20:54:58 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 20:54:58 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 20:54:58 DEBUG] [parse_args] SCHEMA_ONLY=Y[2022-05-15 20:54:58 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 20:54:58 TRACE] lv_case='ALL case 1 - Dump all schema only'[2022-05-15 20:54:58 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205458_dumpall.log[2022-05-15 20:54:58 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205458_restore.log[2022-05-15 20:54:58 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 20:54:58 INFO] All shema is being dumped. pid = 118554[2022-05-15 20:54:59 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only
Dump all schema and data
1. The instance size is quite small
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M ALL[2022-05-15 20:56:15 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205615.log[2022-05-15 20:56:15 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' --'[2022-05-15 20:56:15 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 20:56:15 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 20:56:15 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 20:56:15 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 20:56:15 TRACE] lv_case='ALL case 2 - Dump all schema and data'[2022-05-15 20:56:15 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205615_dumpall.log[2022-05-15 20:56:15 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205615_restore.log[2022-05-15 20:56:15 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 20:56:15 INFO] All shema and data is being dumped. pid = 118981[2022-05-15 20:56:16 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 2 - Dump all schema and data
Dump specified databases
2. You just don't need other databases
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -g 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Then dump specified databases one by one manually.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M ALL -D "alvindb dbadaily"[2022-05-15 20:57:23 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722.log[2022-05-15 20:57:23 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -D 'alvindb dbadaily' --'[2022-05-15 20:57:23 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 20:57:23 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 20:57:23 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 20:57:23 DEBUG] [parse_args] DATABASES=alvindb dbadaily[2022-05-15 20:57:23 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES=alvindb dbadaily DBTABLES=[2022-05-15 20:57:23 TRACE] lv_case='ALL case 3 - Dump specified databases'[2022-05-15 20:57:23 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_dumpall.log[2022-05-15 20:57:23 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_restore.log[2022-05-15 20:57:23 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 20:57:23 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 3 - Dump specified databases. Users dumped.[2022-05-15 20:57:23 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_create_alvindb.sql[2022-05-15 20:57:23 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_dump_alvindb.log[2022-05-15 20:57:23 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_restore_alvindb.log[2022-05-15 20:57:23 INFO] Database alvindb created[2022-05-15 20:57:23 INFO] Database alvindb is being dumped. pid = 119414real 0m0.093suser 0m0.007ssys 0m0.006s[2022-05-15 20:57:23 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 3 - Dump specified databases. Database alvindb dump finished.[2022-05-15 20:57:26 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_create_dbadaily.sql[2022-05-15 20:57:26 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_dump_dbadaily.log[2022-05-15 20:57:26 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_0_205722_restore_dbadaily.log[2022-05-15 20:57:26 INFO] Database dbadaily created[2022-05-15 20:57:26 INFO] Database dbadaily is being dumped. pid = 119414real 0m0.082suser 0m0.007ssys 0m0.005s[2022-05-15 20:57:26 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 3 - Dump specified databases. Database dbadaily dump finished.
Dump all databases in parallel
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -g 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Then dump all databases one by one in parallel manually.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M ALL -L -t 3[2022-05-15 20:58:18 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818.log[2022-05-15 20:58:18 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -L -t '3' --'[2022-05-15 20:58:18 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 20:58:18 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 20:58:18 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 20:58:18 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 20:58:18 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 20:58:18 INFO] DUMP_MODE=ALL PARALLEL_IND=Y DATABASES= DBTABLES=[2022-05-15 20:58:18 TRACE] lv_case='ALL case 4 - Dump all databases in parallel'[2022-05-15 20:58:18 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_dumpall.log[2022-05-15 20:58:18 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_restore.log[2022-05-15 20:58:18 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 20:58:18 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 4 - Dump all databases in parallel. Users dumped.[2022-05-15 20:58:18 INFO] DATABASES to be dumped: alvindbdbadailypostgrestestdb[2022-05-15 20:58:18 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_create_alvindb.sql[2022-05-15 20:58:18 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_dump_alvindb.log[2022-05-15 20:58:18 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_restore_alvindb.log[2022-05-15 20:58:18 INFO] Database alvindb created[2022-05-15 20:58:18 INFO] Database alvindb is being dumped in parallel. pid = 120250real 0m0.091suser 0m0.009ssys 0m0.004s[2022-05-15 20:58:18 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 4 - Dump all databases in parallel. Database alvindb dump finished.[2022-05-15 20:58:21 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_create_dbadaily.sql[2022-05-15 20:58:21 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_dump_dbadaily.log[2022-05-15 20:58:21 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_restore_dbadaily.log[2022-05-15 20:58:21 INFO] Database dbadaily created[2022-05-15 20:58:21 INFO] Database dbadaily is being dumped in parallel. pid = 120323real 0m0.079suser 0m0.010ssys 0m0.002s[2022-05-15 20:58:21 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 4 - Dump all databases in parallel. Database dbadaily dump finished.[2022-05-15 20:58:24 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_dump_postgres.log[2022-05-15 20:58:24 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_restore_postgres.log[2022-05-15 20:58:24 INFO] Database postgres created[2022-05-15 20:58:24 INFO] Database postgres is being dumped in parallel. pid = 120376real 0m0.058suser 0m0.005ssys 0m0.004s[2022-05-15 20:58:24 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 4 - Dump all databases in parallel. Database postgres dump finished.[2022-05-15 20:58:27 INFO] Database testdb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_create_testdb.sql[2022-05-15 20:58:27 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_dump_testdb.log[2022-05-15 20:58:27 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205818_restore_testdb.log[2022-05-15 20:58:27 INFO] Database testdb created[2022-05-15 20:58:27 INFO] Database testdb is being dumped in parallel. pid = 120464real 0m0.083suser 0m0.007ssys 0m0.005s[2022-05-15 20:58:27 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 4 - Dump all databases in parallel. Database testdb dump finished.
Dump specified databases in parallel
2. You need to minimize the dump time to reduce the affect on the application
time "${PGBIN}"/pg_dumpall -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -g 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -e &>>"${lv_restore_log}"Then dump specified databases one by one in parallel manually.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M ALL -D "alvindb dbadaily" -L -t 3[2022-05-15 20:59:37 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937.log[2022-05-15 20:59:37 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -D 'alvindb dbadaily' -L -t '3' --'[2022-05-15 20:59:37 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 20:59:37 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 20:59:37 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 20:59:37 DEBUG] [parse_args] DATABASES=alvindb dbadaily[2022-05-15 20:59:37 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 20:59:37 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 20:59:37 INFO] DUMP_MODE=ALL PARALLEL_IND=Y DATABASES=alvindb dbadaily DBTABLES=[2022-05-15 20:59:37 TRACE] lv_case='ALL case 5 - Dump specified databases in parallel'[2022-05-15 20:59:37 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_dumpall.log[2022-05-15 20:59:37 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_restore.log[2022-05-15 20:59:37 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 20:59:37 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 5 - Dump specified databases in parallel. Users dumped.[2022-05-15 20:59:37 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_create_alvindb.sql[2022-05-15 20:59:37 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_dump_alvindb.log[2022-05-15 20:59:37 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_restore_alvindb.log[2022-05-15 20:59:37 INFO] Database alvindb created[2022-05-15 20:59:37 INFO] Database alvindb is being dumped in parallel. pid = 121018real 0m0.093suser 0m0.009ssys 0m0.004s[2022-05-15 20:59:37 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 5 - Dump specified databases in parallel. Database alvindb dump finished.[2022-05-15 20:59:40 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_create_dbadaily.sql[2022-05-15 20:59:40 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_dump_dbadaily.log[2022-05-15 20:59:40 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_205937_restore_dbadaily.log[2022-05-15 20:59:40 INFO] Database dbadaily created[2022-05-15 20:59:40 INFO] Database dbadaily is being dumped in parallel. pid = 121085real 0m0.083suser 0m0.009ssys 0m0.003s[2022-05-15 20:59:40 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: ALL case 5 - Dump specified databases in parallel. Database dbadaily dump finished.
DBS
-u or --users to always dump users.Dump all databases
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M DBS[2022-05-15 21:04:16 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416.log[2022-05-15 21:04:16 TRACE] [parse_args] lv_valid_args: ' -v -M 'DBS' --'[2022-05-15 21:04:16 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:04:16 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:04:16 DEBUG] [parse_args] DUMP_MODE=DBS[2022-05-15 21:04:16 INFO] DUMP_MODE=DBS PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:04:16 TRACE] lv_case='DBS case 1 - Dump all databases'[2022-05-15 21:04:16 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_dumpall.log[2022-05-15 21:04:16 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_restore.log[2022-05-15 21:04:16 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:04:16 INFO] DATABASES to be dumped: alvindbdbadailypostgrestestdb[2022-05-15 21:04:16 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_create_alvindb.sql[2022-05-15 21:04:16 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_dump_alvindb.log[2022-05-15 21:04:16 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_restore_alvindb.log[2022-05-15 21:04:16 INFO] Database alvindb created[2022-05-15 21:04:16 INFO] Database alvindb is being dumped. pid = 121991real 0m0.092suser 0m0.008ssys 0m0.005s[2022-05-15 21:04:16 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 1 - Dump all databases. Database alvindb dump finished.[2022-05-15 21:04:19 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_create_dbadaily.sql[2022-05-15 21:04:19 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_dump_dbadaily.log[2022-05-15 21:04:19 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_restore_dbadaily.log[2022-05-15 21:04:19 INFO] Database dbadaily created[2022-05-15 21:04:19 INFO] Database dbadaily is being dumped. pid = 121991real 0m0.083suser 0m0.008ssys 0m0.005s[2022-05-15 21:04:19 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 1 - Dump all databases. Database dbadaily dump finished.[2022-05-15 21:04:22 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_dump_postgres.log[2022-05-15 21:04:22 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_restore_postgres.log[2022-05-15 21:04:22 INFO] Database postgres created[2022-05-15 21:04:22 INFO] Database postgres is being dumped. pid = 121991real 0m0.061suser 0m0.007ssys 0m0.002s[2022-05-15 21:04:22 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 1 - Dump all databases. Database postgres dump finished.[2022-05-15 21:04:25 INFO] Database testdb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_create_testdb.sql[2022-05-15 21:04:25 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_dump_testdb.log[2022-05-15 21:04:25 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210416_restore_testdb.log[2022-05-15 21:04:25 INFO] Database testdb created[2022-05-15 21:04:25 INFO] Database testdb is being dumped. pid = 121991real 0m0.084suser 0m0.008ssys 0m0.004s[2022-05-15 21:04:25 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 1 - Dump all databases. Database testdb dump finished.
Dump specified databases
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M DBS -D "alvindb dbadaily"[2022-05-15 21:05:10 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510.log[2022-05-15 21:05:10 TRACE] [parse_args] lv_valid_args: ' -v -M 'DBS' -D 'alvindb dbadaily' --'[2022-05-15 21:05:10 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:05:10 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:05:10 DEBUG] [parse_args] DUMP_MODE=DBS[2022-05-15 21:05:10 DEBUG] [parse_args] DATABASES=alvindb dbadaily[2022-05-15 21:05:10 INFO] DUMP_MODE=DBS PARALLEL_IND= DATABASES=alvindb dbadaily DBTABLES=[2022-05-15 21:05:10 TRACE] lv_case='DBS case 2 - Dump specified databases'[2022-05-15 21:05:10 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_dumpall.log[2022-05-15 21:05:10 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_restore.log[2022-05-15 21:05:10 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:05:10 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_create_alvindb.sql[2022-05-15 21:05:10 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_dump_alvindb.log[2022-05-15 21:05:10 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_restore_alvindb.log[2022-05-15 21:05:10 INFO] Database alvindb created[2022-05-15 21:05:10 INFO] Database alvindb is being dumped. pid = 122647real 0m0.081suser 0m0.008ssys 0m0.006s[2022-05-15 21:05:11 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 2 - Dump specified databases. Database alvindb dump finished.[2022-05-15 21:05:14 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_create_dbadaily.sql[2022-05-15 21:05:14 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_dump_dbadaily.log[2022-05-15 21:05:14 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210510_restore_dbadaily.log[2022-05-15 21:05:14 INFO] Database dbadaily created[2022-05-15 21:05:14 INFO] Database dbadaily is being dumped. pid = 122647real 0m0.074suser 0m0.006ssys 0m0.006s[2022-05-15 21:05:14 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 2 - Dump specified databases. Database dbadaily dump finished.
Dump all databases in parallel
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}" &bash pg_dump.sh -v -M DBS -L -t 3[2022-05-15 21:05:53 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553.log[2022-05-15 21:05:53 TRACE] [parse_args] lv_valid_args: ' -v -M 'DBS' -L -t '3' --'[2022-05-15 21:05:53 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:05:53 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:05:53 DEBUG] [parse_args] DUMP_MODE=DBS[2022-05-15 21:05:53 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:05:53 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:05:53 INFO] DUMP_MODE=DBS PARALLEL_IND=Y DATABASES= DBTABLES=[2022-05-15 21:05:53 TRACE] lv_case='DBS case 3 - Dump all databases in parallel'[2022-05-15 21:05:53 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_dumpall.log[2022-05-15 21:05:53 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_restore.log[2022-05-15 21:05:53 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:05:53 INFO] DATABASES to be dumped: alvindbdbadailypostgrestestdb[2022-05-15 21:05:53 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_create_alvindb.sql[2022-05-15 21:05:53 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_dump_alvindb.log[2022-05-15 21:05:53 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_restore_alvindb.log[2022-05-15 21:05:53 INFO] Database alvindb created[2022-05-15 21:05:53 INFO] Database alvindb is being dumped in parallel. pid = 123557real 0m0.091suser 0m0.010ssys 0m0.003s[2022-05-15 21:05:53 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 3 - Dump all databases in parallel. Database alvindb dump finished.[2022-05-15 21:05:56 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_create_dbadaily.sql[2022-05-15 21:05:56 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_dump_dbadaily.log[2022-05-15 21:05:56 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_restore_dbadaily.log[2022-05-15 21:05:56 INFO] Database dbadaily created[2022-05-15 21:05:56 INFO] Database dbadaily is being dumped in parallel. pid = 123619real 0m0.081suser 0m0.010ssys 0m0.002s[2022-05-15 21:05:56 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 3 - Dump all databases in parallel. Database dbadaily dump finished.[2022-05-15 21:05:59 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_dump_postgres.log[2022-05-15 21:05:59 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_restore_postgres.log[2022-05-15 21:05:59 INFO] Database postgres created[2022-05-15 21:05:59 INFO] Database postgres is being dumped in parallel. pid = 123672real 0m0.060suser 0m0.004ssys 0m0.005s[2022-05-15 21:05:59 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 3 - Dump all databases in parallel. Database postgres dump finished.[2022-05-15 21:06:02 INFO] Database testdb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_create_testdb.sql[2022-05-15 21:06:02 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_dump_testdb.log[2022-05-15 21:06:02 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210553_restore_testdb.log[2022-05-15 21:06:02 INFO] Database testdb created[2022-05-15 21:06:02 INFO] Database testdb is being dumped in parallel. pid = 123737real 0m0.081suser 0m0.009ssys 0m0.003s[2022-05-15 21:06:02 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 3 - Dump all databases in parallel. Database testdb dump finished.
Dump specified databases in parallel
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M DBS -D "alvindb dbadaily" -L -t 3[2022-05-15 21:06:51 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651.log[2022-05-15 21:06:51 TRACE] [parse_args] lv_valid_args: ' -v -M 'DBS' -D 'alvindb dbadaily' -L -t '3' --'[2022-05-15 21:06:51 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:06:51 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:06:51 DEBUG] [parse_args] DUMP_MODE=DBS[2022-05-15 21:06:52 DEBUG] [parse_args] DATABASES=alvindb dbadaily[2022-05-15 21:06:52 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:06:52 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:06:52 INFO] DUMP_MODE=DBS PARALLEL_IND=Y DATABASES=alvindb dbadaily DBTABLES=[2022-05-15 21:06:52 TRACE] lv_case='DBS case 4 - Dump specified databases in parallel'[2022-05-15 21:06:52 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_dumpall.log[2022-05-15 21:06:52 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_restore.log[2022-05-15 21:06:52 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:06:52 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_create_alvindb.sql[2022-05-15 21:06:52 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_dump_alvindb.log[2022-05-15 21:06:52 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_restore_alvindb.log[2022-05-15 21:06:52 INFO] Database alvindb created[2022-05-15 21:06:52 INFO] Database alvindb is being dumped in parallel. pid = 124191real 0m0.111suser 0m0.005ssys 0m0.008s[2022-05-15 21:06:52 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 4 - Dump specified databases in parallel. Database alvindb dump finished.[2022-05-15 21:06:55 INFO] Database dbadaily CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_create_dbadaily.sql[2022-05-15 21:06:55 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_dump_dbadaily.log[2022-05-15 21:06:55 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210651_restore_dbadaily.log[2022-05-15 21:06:55 INFO] Database dbadaily created[2022-05-15 21:06:55 INFO] Database dbadaily is being dumped in parallel. pid = 124253real 0m0.075suser 0m0.007ssys 0m0.005s[2022-05-15 21:06:55 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DBS case 4 - Dump specified databases in parallel. Database dbadaily dump finished.
DB
-u or --users to always dump users.Dump all tables
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M DB -d alvindb[2022-05-15 21:07:46 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746.log[2022-05-15 21:07:46 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' --'[2022-05-15 21:07:46 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:07:46 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:07:46 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:07:46 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:07:46 INFO] DUMP_MODE=DB PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:07:46 TRACE] lv_case='DB case 1 - Dump all tables'[2022-05-15 21:07:46 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746_dumpall.log[2022-05-15 21:07:46 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746_restore.log[2022-05-15 21:07:46 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:07:46 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746_create_alvindb.sql[2022-05-15 21:07:46 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746_dump_alvindb.log[2022-05-15 21:07:46 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_210746_restore_alvindb.log[2022-05-15 21:07:46 INFO] Database alvindb created[2022-05-15 21:07:46 INFO] Database alvindb is being dumped. pid = 124384real 0m0.088suser 0m0.008ssys 0m0.006s[2022-05-15 21:07:47 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 1 - Dump all tables. Database alvindb dump finished.
Dump all tables with exclusion
-T option to specify table pattern. Please note that the table pattern is not regular expression and in rare cases like same table name exists in in various schema it might not work as expected.time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" -T "public|alvin.tb_test|tb_alvindb_test" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"You can also use multiple -T options to specify all tables to be excluded.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" -T "public.tb_test" -T "alvin.tb_alvindb_test" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"-C ) first to check matching tables. In rare cases, please use PostgreSQL pg_dump command.bash pg_dump.sh -v -M DB -d alvindb -E "public.tb_test alvin.tb_alvindb_test"[2022-05-15 21:12:33 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233.log[2022-05-15 21:12:33 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -E 'public.tb_test alvin.tb_alvindb_test' --'[2022-05-15 21:12:33 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:12:33 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:12:33 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:12:33 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:12:33 DEBUG] [parse_args] DBTABLES_EXCLUDE=public.tb_test alvin.tb_alvindb_test[2022-05-15 21:12:33 INFO] DUMP_MODE=DB PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:12:33 TRACE] lv_case='DB case 2 - Dump all tables with exclusion'[2022-05-15 21:12:33 DEBUG] lv_tables= public.tb_test alvin.tb_alvindb_test[2022-05-15 21:12:33 DEBUG] lv_tables_exp=public|alvin.tb_test|tb_alvindb_test[2022-05-15 21:12:33 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-----------------+-------+-------+-------+-------------alvin | tb_alvindb_test | table | alvin | 32 kB |public | tb_test | table | alvin | 32 kB |(2 rows)[2022-05-15 21:12:33 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233_dumpall.log[2022-05-15 21:12:33 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233_restore.log[2022-05-15 21:12:33 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:12:33 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233_create_alvindb.sql[2022-05-15 21:12:33 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233_dump_alvindb.log[2022-05-15 21:12:33 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211233_restore_alvindb.log[2022-05-15 21:12:33 INFO] Database alvindb created[2022-05-15 21:12:33 INFO] Database alvindb is being dumped. pid = 125335real 0m0.112suser 0m0.009ssys 0m0.003s[2022-05-15 21:12:33 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 2 - Dump all tables with exclusion. Database alvindb dump with exclusion finished.
Dump all tables, specified tables are dumped in parallel
1. PostgreSQL database to be dumped contains one or more huge tables or time consuming tables
-T option to specify table pattern. Please note that the table pattern is not regular expression and in rare cases like same table name exists in in various schema it might not work as expected.time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" -T "public|alvin.tb_vacuum|tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"You can also use multiple -T options to specify all tables to be excluded.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "public.tb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "alvin.tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -L -t 3[2022-05-15 21:13:26 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326.log[2022-05-15 21:13:26 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' -L -t '3' --'[2022-05-15 21:13:26 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:13:26 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:13:26 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:13:26 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:13:26 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:13:26 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:13:26 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:13:26 INFO] DUMP_MODE=DB PARALLEL_IND=Y DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:13:26 TRACE] lv_case='DB case 7 - Dump all tables, specified tables are dumped in parallel'[2022-05-15 21:13:26 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:13:26 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum[2022-05-15 21:13:26 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(2 rows)[2022-05-15 21:13:26 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_dumpall.log[2022-05-15 21:13:26 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_restore.log[2022-05-15 21:13:26 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:13:26 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_create_alvindb.sql[2022-05-15 21:13:26 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_dump_alvindb.log[2022-05-15 21:13:26 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_restore_alvindb.log[2022-05-15 21:13:26 INFO] Database alvindb created[2022-05-15 21:13:26 INFO] Database alvindb is being dumped in parallel. pid = 126142real 0m0.089suser 0m0.006ssys 0m0.006s[2022-05-15 21:13:26 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 7 - Dump all tables, specified tables are dumped in parallel. Database alvindb dump with exclusion finished.[2022-05-15 21:13:29 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_dump_public.tb_vacuum.log[2022-05-15 21:13:29 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_restore_public.tb_vacuum.log[2022-05-15 21:13:29 INFO] Table public.tb_vacuum is being dumped in parallel. pid = 126203real 0m0.074suser 0m0.008ssys 0m0.003s[2022-05-15 21:13:29 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 7 - Dump all tables, specified tables are dumped in parallel. Table public.tb_vacuum dump finished.[2022-05-15 21:13:32 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_dump_alvin.tb_alvindb_vacuum.log[2022-05-15 21:13:32 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211326_restore_alvin.tb_alvindb_vacuum.log[2022-05-15 21:13:32 INFO] Table alvin.tb_alvindb_vacuum is being dumped in parallel. pid = 126246real 0m0.072suser 0m0.006ssys 0m0.004s[2022-05-15 21:13:32 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 7 - Dump all tables, specified tables are dumped in parallel. Table alvin.tb_alvindb_vacuum dump finished.
Dump all tables with exclusion, specified tables are dumped in parallel
-T option to specify table pattern. Please note that the table pattern is not regular expression and in rare cases like same table name exists in in various schema it might not work as expected.time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" -T "public|alvin.tb_vacuum|tb_alvindb_vacuum|tb_test|tb_alvindb_test" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"You can also use multiple -T options to specify all tables to be excluded.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${lv_dbname}" -T "public.tb_test" -T "alvin.tb_alvindb_test" -T "public.tb_vacuum" -T "alvin.tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${lv_dbname}" -e &>>"${lv_restore_log}"Then dump specified tables in parallel.
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "public.tb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "alvin.tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -E "public.tb_test alvin.tb_alvindb_test" -L -t 3[2022-05-15 21:13:57 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356.log[2022-05-15 21:13:57 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' -E 'public.tb_test alvin.tb_alvindb_test' -L -t '3' --'[2022-05-15 21:13:57 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:13:57 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:13:57 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:13:57 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:13:57 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:13:57 DEBUG] [parse_args] DBTABLES_EXCLUDE=public.tb_test alvin.tb_alvindb_test[2022-05-15 21:13:57 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:13:57 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:13:57 INFO] DUMP_MODE=DB PARALLEL_IND=Y DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:13:57 TRACE] lv_case='DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel'[2022-05-15 21:13:57 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum public.tb_test alvin.tb_alvindb_test[2022-05-15 21:13:57 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum|tb_test|tb_alvindb_test[2022-05-15 21:13:57 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_test | table | alvin | 32 kB |alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_test | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(4 rows)[2022-05-15 21:13:57 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_dumpall.log[2022-05-15 21:13:57 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_restore.log[2022-05-15 21:13:57 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:13:57 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_create_alvindb.sql[2022-05-15 21:13:57 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_dump_alvindb.log[2022-05-15 21:13:57 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_restore_alvindb.log[2022-05-15 21:13:57 INFO] Database alvindb created[2022-05-15 21:13:57 INFO] Database alvindb is being dumped in parallel. pid = 126694real 0m0.080suser 0m0.009ssys 0m0.003s[2022-05-15 21:13:57 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Database alvindb dump with exclusion finished.[2022-05-15 21:14:00 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_dump_public.tb_vacuum.log[2022-05-15 21:14:00 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_restore_public.tb_vacuum.log[2022-05-15 21:14:00 INFO] Table public.tb_vacuum is being dumped in parallel. pid = 126737real 0m0.075suser 0m0.006ssys 0m0.004s[2022-05-15 21:14:00 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Table public.tb_vacuum dump finished.[2022-05-15 21:14:03 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_dump_alvin.tb_alvindb_vacuum.log[2022-05-15 21:14:03 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211356_restore_alvin.tb_alvindb_vacuum.log[2022-05-15 21:14:03 INFO] Table alvin.tb_alvindb_vacuum is being dumped in parallel. pid = 126783real 0m0.071suser 0m0.006ssys 0m0.004s[2022-05-15 21:14:03 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Table alvin.tb_alvindb_vacuum dump finished.
TABLE
Dump specified tables one by one
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "public.tb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}"time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "alvin.tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}"Easy Dump command
bash pg_dump.sh -v -M TABLE -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum"[2022-05-15 21:14:47 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447.log[2022-05-15 21:14:47 TRACE] [parse_args] lv_valid_args: ' -v -M 'TABLE' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' --'[2022-05-15 21:14:47 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:14:47 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:14:47 DEBUG] [parse_args] DUMP_MODE=TABLE[2022-05-15 21:14:47 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:14:47 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:14:47 INFO] DUMP_MODE=TABLE PARALLEL_IND= DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:14:47 TRACE] lv_case='TABLE case 1 - Dump specified tables one by one'[2022-05-15 21:14:47 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:14:47 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum[2022-05-15 21:14:47 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(2 rows)[2022-05-15 21:14:47 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_dumpall.log[2022-05-15 21:14:47 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_restore.log[2022-05-15 21:14:47 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:14:47 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_dump_public.tb_vacuum.log[2022-05-15 21:14:47 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_restore_public.tb_vacuum.log[2022-05-15 21:14:47 INFO] Table public.tb_vacuum is being dumped. pid = 126909real 0m0.075suser 0m0.007ssys 0m0.005s[2022-05-15 21:14:48 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: TABLE case 1 - Dump specified tables one by one. Table public.tb_vacuum dump finished.[2022-05-15 21:14:51 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_dump_alvin.tb_alvindb_vacuum.log[2022-05-15 21:14:51 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211447_restore_alvin.tb_alvindb_vacuum.log[2022-05-15 21:14:51 INFO] Table alvin.tb_alvindb_vacuum is being dumped. pid = 126909real 0m0.066suser 0m0.008ssys 0m0.004s[2022-05-15 21:14:51 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: TABLE case 1 - Dump specified tables one by one. Table alvin.tb_alvindb_vacuum dump finished.
Dump specified tables in parallel
2. You are achiving tables regularly, and need to speed up the process
time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "public.tb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &time "${PGBIN}"/pg_dump -v -U "${DBUSER}" -h "${DBHOST}" -p "${DBPORT}" -d "${DBNAME}" -t "alvin.tb_alvindb_vacuum" 2>>"${lv_dump_log}" | "${PGBIN}"/psql -U postgres -p "${DBPORT_TARGET}" -d "${DBNAME}" -e &>>"${lv_restore_log}" &Easy Dump command
bash pg_dump.sh -v -M TABLE -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -L -t 3[2022-05-15 21:15:45 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545.log[2022-05-15 21:15:45 TRACE] [parse_args] lv_valid_args: ' -v -M 'TABLE' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' -L -t '3' --'[2022-05-15 21:15:45 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:15:45 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:15:45 DEBUG] [parse_args] DUMP_MODE=TABLE[2022-05-15 21:15:45 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:15:45 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:15:45 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:15:45 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:15:45 INFO] DUMP_MODE=TABLE PARALLEL_IND=Y DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:15:45 TRACE] lv_case='TABLE case 2 - Dump specified tables in parallel'[2022-05-15 21:15:45 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:15:45 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum[2022-05-15 21:15:45 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(2 rows)[2022-05-15 21:15:45 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_dumpall.log[2022-05-15 21:15:45 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_restore.log[2022-05-15 21:15:45 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:15:45 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_dump_public.tb_vacuum.log[2022-05-15 21:15:45 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_restore_public.tb_vacuum.log[2022-05-15 21:15:45 INFO] Table public.tb_vacuum is being dumped in parallel. pid = 127742real 0m0.067suser 0m0.007ssys 0m0.004s[2022-05-15 21:15:45 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: TABLE case 2 - Dump specified tables in parallel. Table public.tb_vacuum dump finished.[2022-05-15 21:15:48 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_dump_alvin.tb_alvindb_vacuum.log[2022-05-15 21:15:48 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211545_restore_alvin.tb_alvindb_vacuum.log[2022-05-15 21:15:48 INFO] Table alvin.tb_alvindb_vacuum is being dumped in parallel. pid = 127785real 0m0.075suser 0m0.008ssys 0m0.003s[2022-05-15 21:15:48 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: TABLE case 2 - Dump specified tables in parallel. Table alvin.tb_alvindb_vacuum dump finished.
Always dump users
bash pg_dump.sh -v -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -E "public.tb_test alvin.tb_alvindb_test" -L -t 3 -u[2022-05-15 21:22:20 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220.log[2022-05-15 21:22:20 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' -E 'public.tb_test alvin.tb_alvindb_test' -L -t '3' -u --'[2022-05-15 21:22:20 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:22:20 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:22:20 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:22:20 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:22:20 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:22:20 DEBUG] [parse_args] DBTABLES_EXCLUDE=public.tb_test alvin.tb_alvindb_test[2022-05-15 21:22:20 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:22:20 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:22:20 DEBUG] [parse_args] DUMP_ALL_USERS=Y[2022-05-15 21:22:20 INFO] DUMP_MODE=DB PARALLEL_IND=Y DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:22:20 TRACE] lv_case='DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel'[2022-05-15 21:22:20 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum public.tb_test alvin.tb_alvindb_test[2022-05-15 21:22:20 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum|tb_test|tb_alvindb_test[2022-05-15 21:22:20 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_test | table | alvin | 32 kB |alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_test | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(4 rows)[2022-05-15 21:22:20 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_dumpall.log[2022-05-15 21:22:20 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_restore.log[2022-05-15 21:22:20 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:22:20 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Users dumped.[2022-05-15 21:22:20 INFO] Database alvindb CREATE sql file: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_create_alvindb.sql[2022-05-15 21:22:20 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_dump_alvindb.log[2022-05-15 21:22:20 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_restore_alvindb.log[2022-05-15 21:22:20 INFO] Database alvindb created[2022-05-15 21:22:20 INFO] Database alvindb is being dumped in parallel. pid = 130090real 0m0.083suser 0m0.008ssys 0m0.004s[2022-05-15 21:22:20 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Database alvindb dump with exclusion finished.[2022-05-15 21:22:23 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_dump_public.tb_vacuum.log[2022-05-15 21:22:23 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_restore_public.tb_vacuum.log[2022-05-15 21:22:23 INFO] Table public.tb_vacuum is being dumped in parallel. pid = 130135real 0m0.076suser 0m0.006ssys 0m0.005s[2022-05-15 21:22:23 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Table public.tb_vacuum dump finished.[2022-05-15 21:22:26 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_dump_alvin.tb_alvindb_vacuum.log[2022-05-15 21:22:26 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212220_restore_alvin.tb_alvindb_vacuum.log[2022-05-15 21:22:26 INFO] Table alvin.tb_alvindb_vacuum is being dumped in parallel. pid = 130192real 0m0.076suser 0m0.007ssys 0m0.004s[2022-05-15 21:22:26 TRACE] Message sent: [SUCCESS] alvindb2.dbadaily.com: DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel. Table alvin.tb_alvindb_vacuum dump finished.
Check mode
bash pg_dump.sh -v -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum" -E "public.tb_test alvin.tb_alvindb_test" -L -t 3 -u -C[2022-05-15 21:22:29 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212229.log[2022-05-15 21:22:29 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' -E 'public.tb_test alvin.tb_alvindb_test' -L -t '3' -u -C --'[2022-05-15 21:22:29 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:22:29 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:22:29 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:22:29 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:22:29 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:22:29 DEBUG] [parse_args] DBTABLES_EXCLUDE=public.tb_test alvin.tb_alvindb_test[2022-05-15 21:22:29 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:22:29 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:22:29 DEBUG] [parse_args] DUMP_ALL_USERS=Y[2022-05-15 21:22:29 DEBUG] [parse_args] CHECK_MODE=Y[2022-05-15 21:22:29 INFO] DUMP_MODE=DB PARALLEL_IND=Y DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:22:29 TRACE] lv_case='DB case 8 - Dump all tables with exclusion, specified tables are dumped in parallel'[2022-05-15 21:22:29 DEBUG] lv_tables=public.tb_vacuum alvin.tb_alvindb_vacuum public.tb_test alvin.tb_alvindb_test[2022-05-15 21:22:29 DEBUG] lv_tables_exp=public|alvin.tb_vacuum|tb_alvindb_vacuum|tb_test|tb_alvindb_test[2022-05-15 21:22:29 INFO] Matching tables:List of relationsSchema | Name | Type | Owner | Size | Description--------+-------------------+-------+-------+-------+-------------alvin | tb_alvindb_test | table | alvin | 32 kB |alvin | tb_alvindb_vacuum | table | alvin | 32 kB |public | tb_test | table | alvin | 32 kB |public | tb_vacuum | table | alvin | 32 kB |(4 rows)[2022-05-15 21:22:29 INFO] lv_dump_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212229_dumpall.log[2022-05-15 21:22:29 INFO] lv_restore_log: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212229_restore.log[2022-05-15 21:22:29 INFO] schema file exists: /data/scripts/easybash/easydump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 21:22:29 INFO] CHECK MODE. Skip dumping users.[2022-05-15 21:22:29 INFO] CHECK MODE. Skip dumping databases.[2022-05-15 21:22:29 INFO] CHECK MODE. Skip dumping tables.
Failure notificatons
password authentication failed
$ bash pg_dump.sh -v -M ALL -s[2022-05-15 15:46:52 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154652.log[2022-05-15 15:46:52 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -s --'[2022-05-15 15:46:52 TRACE] [parse_args] config file found: /data/scripts/easybash/pg_dump/config.sh[2022-05-15 15:46:52 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 15:46:52 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 15:46:52 DEBUG] [parse_args] SCHEMA_ONLY=Y[2022-05-15 15:46:52 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 15:46:52 TRACE] lv_case='ALL case 1 - Dump all schema only'[2022-05-15 15:46:52 INFO] lv_dump_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154652_dumpall.log[2022-05-15 15:46:52 INFO] lv_restore_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154652_restore.log[2022-05-15 15:46:52 INFO] schema file exists: /data/scripts/easybash/pg_dump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 15:46:52 INFO] All shema is being dumped. pid = 75553real 0m0.011suser 0m0.001ssys 0m0.005s[2022-05-15 15:46:52 WARNING] Dump failed. Please check errors in log file: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154652_dumpall.logpg_dumpall: could not connect to database "template1": FATAL: password authentication failed for user "postgres"[2022-05-15 15:46:52 DEBUG] lv_error_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154652_errors.log[2022-05-15 15:46:52 TRACE] Message sent: [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:pg_dumpall: could not connect to database template1: FATAL: password authentication failed for user postgres[2022-05-15 15:46:52 FATAL] [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:pg_dumpall: could not connect to database template1: FATAL: password authentication failed for user postgres. ln_flag: 1
wrong ports
$ bash pg_dump.sh -v -M ALL -s[2022-05-15 15:45:50 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154550.log[2022-05-15 15:45:50 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -s --'[2022-05-15 15:45:50 TRACE] [parse_args] config file found: /data/scripts/easybash/pg_dump/config.sh[2022-05-15 15:45:50 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 15:45:50 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 15:45:50 DEBUG] [parse_args] SCHEMA_ONLY=Y[2022-05-15 15:45:50 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 15:45:50 TRACE] lv_case='ALL case 1 - Dump all schema only'[2022-05-15 15:45:50 INFO] lv_dump_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154550_dumpall.log[2022-05-15 15:45:50 INFO] lv_restore_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154550_restore.log[2022-05-15 15:45:50 WARNING] Dump failed. Please check errors in log file: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154550_dumpall.logpg_dumpall: could not connect to database "template1": could not connect to server: Connection refusedIs the server running on host "alvindb1.dbadaily.com" (10.20.20.1) and acceptingTCP/IP connections on port 6432?[2022-05-15 15:45:50 DEBUG] lv_error_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154550_errors.log# source database server host or socket directory[2022-05-15 15:45:50 TRACE] Message sent: [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:pg_dumpall: could not connect to database template1: could not connect to server: Connection refusedIs the server running on host alvindb1.dbadaily.com (10.20.20.1) and acceptingTCP/IP connections on port 6432?[2022-05-15 15:45:50 FATAL] [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:pg_dumpall: could not connect to database template1: could not connect to server: Connection refusedIs the server running on host alvindb1.dbadaily.com (10.20.20.1) and acceptingTCP/IP connections on port 6432?. ln_flag: 1
Below show the error messages when given wrong target port
$ bash pg_dump.sh -v -M ALL -s[2022-05-15 15:46:18 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154618.log[2022-05-15 15:46:18 TRACE] [parse_args] lv_valid_args: ' -v -M 'ALL' -s --'[2022-05-15 15:46:18 TRACE] [parse_args] config file found: /data/scripts/easybash/pg_dump/config.sh[2022-05-15 15:46:18 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 15:46:18 DEBUG] [parse_args] DUMP_MODE=ALL[2022-05-15 15:46:18 DEBUG] [parse_args] SCHEMA_ONLY=Y[2022-05-15 15:46:18 INFO] DUMP_MODE=ALL PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 15:46:18 TRACE] lv_case='ALL case 1 - Dump all schema only'[2022-05-15 15:46:18 INFO] lv_dump_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154618_dumpall.log[2022-05-15 15:46:18 INFO] lv_restore_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154618_restore.log[2022-05-15 15:46:18 INFO] schema file exists: /data/scripts/easybash/pg_dump/logs/202205/20220515/dumpall_schema_alvindb1.dbadaily.com_5432.sql[2022-05-15 15:46:18 INFO] All shema is being dumped. pid = 75087real 0m0.016suser 0m0.002ssys 0m0.002s[2022-05-15 15:46:18 WARNING] Restore failed. Please check errors in log file: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154618_restore.logpsql: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix domain socket "/tmp/.s.PGSQL.6432"?[2022-05-15 15:46:18 DEBUG] lv_error_log: /data/scripts/easybash/pg_dump/logs/202205/20220515/pg_dump_20220515_4_154618_errors.log[2022-05-15 15:46:18 TRACE] Message sent: [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:psql: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix domain socket /tmp/.s.PGSQL.6432?[2022-05-15 15:46:18 FATAL] [FAILURE] alvindb2.dbadaily.com: ALL case 1 - Dump all schema only: ALL case 1 - Dump all schema only:psql: could not connect to server: No such file or directoryIs the server running locally and acceptingconnections on Unix domain socket /tmp/.s.PGSQL.6432?. ln_flag: 2
Invalid option combination
bash pg_dump.sh -v -M DB -d alvindb -T "public.tb_vacuum alvin.tb_alvindb_vacuum"[2022-05-15 21:15:51 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_211551.log[2022-05-15 21:15:51 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -T 'public.tb_vacuum alvin.tb_alvindb_vacuum' --'[2022-05-15 21:15:51 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:15:51 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:15:51 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:15:51 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:15:51 DEBUG] [parse_args] DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:15:51 INFO] DUMP_MODE=DB PARALLEL_IND= DATABASES= DBTABLES=public.tb_vacuum alvin.tb_alvindb_vacuum[2022-05-15 21:15:51 FATAL] In DB mode, -T or --tables is only intended to be used together with -L or --parallel.
bash pg_dump.sh -v -M DB -d alvindb -E "public.tb_test alvin.tb_alvindb_test" -L -t 3[2022-05-15 21:20:05 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212005.log[2022-05-15 21:20:05 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' -d 'alvindb' -E 'public.tb_test alvin.tb_alvindb_test' -L -t '3' --'[2022-05-15 21:20:05 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:20:05 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:20:05 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:20:05 DEBUG] [parse_args] DBNAME=alvindb[2022-05-15 21:20:05 DEBUG] [parse_args] DBTABLES_EXCLUDE=public.tb_test alvin.tb_alvindb_test[2022-05-15 21:20:05 DEBUG] [parse_args] PARALLEL_IND=Y[2022-05-15 21:20:05 DEBUG] [parse_args] SLEEP_TIME=3[2022-05-15 21:20:05 INFO] DUMP_MODE=DB PARALLEL_IND=Y DATABASES= DBTABLES=[2022-05-15 21:20:05 FATAL] In DB mode, -T or --tables is only intended to be used together with -L or --parallel.
DBNAME should NOT be empty in DB mode.
bash pg_dump.sh -v -M TABLE[2022-05-15 21:20:58 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212058.log[2022-05-15 21:20:58 TRACE] [parse_args] lv_valid_args: ' -v -M 'DB' --'[2022-05-15 21:20:58 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:20:58 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:20:58 DEBUG] [parse_args] DUMP_MODE=DB[2022-05-15 21:20:58 INFO] DUMP_MODE=DB PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:20:58 FATAL] DBNAME should NOT be empty in DB mode.
DBTABLES should NOT be empty in TABLE mode.
[2022-05-15 21:21:51 TRACE] [parse_args] LOG_FILE: /data/scripts/easybash/easydump/logs/202205/20220515/pg_dump_20220515_2_212151.log[2022-05-15 21:21:51 TRACE] [parse_args] lv_valid_args: ' -v -M 'TABLE' --'[2022-05-15 21:21:51 TRACE] [parse_args] config file found: /data/scripts/easybash/easydump/config.sh[2022-05-15 21:21:51 DEBUG] [parse_args] VERBOSE=Y[2022-05-15 21:21:51 DEBUG] [parse_args] DUMP_MODE=TABLE[2022-05-15 21:21:51 INFO] DUMP_MODE=TABLE PARALLEL_IND= DATABASES= DBTABLES=[2022-05-15 21:21:51 FATAL] DBTABLES should NOT be empty in TABLE mode.
Conclusion
2. PostgreSQL instance to be upgraded has one database in which there are several huge tables or time consuming tables