Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyLIo-0001Gn-4U for pgsql-admin@arkaria.postgresql.org; Mon, 25 Feb 2019 18:48:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyLIl-0003Ll-V7 for pgsql-admin@arkaria.postgresql.org; Mon, 25 Feb 2019 18:48:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyLIl-0003Le-Ez for pgsql-admin@lists.postgresql.org; Mon, 25 Feb 2019 18:48:31 +0000 Received: from sonic311-14.consmr.mail.bf2.yahoo.com ([74.6.131.124]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gyLIh-0004IR-Ja for pgsql-admin@postgresql.org; Mon, 25 Feb 2019 18:48:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1551120505; bh=7hkBDknqhYll48mMBLTcAxeijeiv0+NXZ1EFl/CR6oI=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=JjGAVdjnedRQyWqvcD2YzseuIK2Zbc8AWHff4RR7Wzpo2jtDwdmkKRMGedJ2rDFWfhdI+7WJLTH3o0EGdkENlk2eBn+Li07gp0omL2tgraSY6Jh7bWs8xQP+NUmg5HGtjmk2RyfT+kK5VCowcf6quMgcmce6mkOlZNGyO4QGF8lV9f8xl9VueMm2+PCZnvG/BgGP96Q2EdqCehwQMBqvwn3/1K5A7Wbot7IC5N1Vi6hplZth3xCCaPzMEjZMb7WNkWqXP9JYGzMHzVa+5SPK5MiloT+2D1FFLeiDdivKZLkLQ5+RRjZtgkjhrzqbc25eLtdRPzfwYXKUc01bfxSSnw== X-YMail-OSG: fsbbQfYVM1lSxQOGkdzy1akGbdYlGUDKPBUEW.L_AX2oTyOXuz9fXq3MbLuHC.J lI7cgq56JFADj8vvXylfSDpX9EHYY5swC1WN7wQKe4oTJYPKfm0_4o4piLvODbjFTgc1MquDBC_V Lyfx94L0HO3gXtUzok_sqX5tA0.Wonskjxljl.3eQHc.MJHDewDb0xfH80VT8hFuIXjsgQ95N92i GUd3fWSk3vIm2sjswMmMnSkOKQbYfR3BjfP5rAxY6W2UqvCBIWFiHT_EaMdJwme4pJ7OLdVa304S lCg8ah05kffe2pDVLcPYIggrQcapvMWOwZiMULyumtQOQ_4gcvsaZNdsjZhtrleCy.PiCmsLwmti qSvQd.WbDj8JtE_G4Cck.IJQAHBnfnCO4B2Z.NTcit4Tb2dAiX0HlY1giMmDigVyPT.MkupnTUfK f7Zq6he1C8qH3rz62WPawB3wQ.4iF.k_zoznFeiR9m3.xP9J8kexRLXWOexN1Gjycd3Ubd.r39xC gckW8uD6QfzqqMWnV17A_sRNMTZZUJXt4I5Abj2v1F94K2cs.BzTekDG8V6q82DvI1noPBo8q8Sr KKrubbpM2GQS5gaSKp0.gaW1NAaBhUH.xQ1KxNaHxgrKKnAyXISS2IbDc7AZHhqk8CrT4u4H07pz olBvGsKpnssWjFs0Aq1NJM1YlpMpb1MKnREMmZoSVmg_gLbiWxK9XhLDpKUIVk5QqhNogQRXrxIw 9_Ci3uB8KStuzlxBzjKwn97vDrA30x6CapVep574ObaEh5I_Dt5Im6i8f7UeUtpdkqqJpMiEA5JE dci89.LmSty4n.OzTSiRSCM6hEwQEB07SJV.WpA23wkCJJHSn3DwEDlzo4EcicedTmdh6ytNTaGe nOdwLw0QU28AYOR.TeJkqT.AoTq1KmQ1bAewSEJAF1gk8jTva_mr94aN39lBZWRAzyB.Su4awG1N Ekw.7AjdP0ZtBWL_rwZwlnHBwTSgOcXy2javmtV5apbT_WpCIu8tb4qaQro1dg3flnFRGTh.TFJ4 yEa_8KFgitAyKEQJQm3caXpw.1gcda897KFVhiR1q_lqck6lfmPQzn0r82bveyg-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.bf2.yahoo.com with HTTP; Mon, 25 Feb 2019 18:48:25 +0000 Date: Mon, 25 Feb 2019 18:48:23 +0000 (UTC) From: Pepe TD Vo Reply-To: Pepe TD Vo To: Shreeyansh Dba Cc: Pgsql-admin Message-ID: <1114844707.4989150.1551120503721@mail.yahoo.com> In-Reply-To: References: <1323549085.4899214.1551113430643.ref@mail.yahoo.com> <1323549085.4899214.1551113430643@mail.yahoo.com> Subject: Re: pg_dumpall: could not connect to database: FATAL MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4989149_1286135336.1551120503711" X-Mailer: WebService/1.1.13123 YahooMailNeo Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36 Content-Length: 85325 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_4989149_1286135336.1551120503711 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Thank you for your information.=C2=A0I saw this document this morning and I= did check my pg_hba.conf and for local host and tried to connect to the te= mplate1/0 and/or other database with postgres fine without prompting me for= the password=C2=A0 #psql -d template0 -U postgrestemplate0-##psql -d template1 -U postgrestemp= late1-##psql -d CIDR -U postgresCIDR-##psql -d postgres -U postgrespostgres= -# and a pg_hba.conf: " #TYPE=C2=A0 DATABASE=C2=A0 =C2=A0 =C2=A0USER=C2=A0 =C2=A0 =C2=A0ADDRESS=C2= =A0 =C2=A0 =C2=A0METHODlocal=C2=A0 =C2=A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0trust= host=C2=A0 =C2=A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0127.0.0.1/32 trusthost= =C2=A0 =C2=A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0::1/128=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0trust #allo replication connections from localhost, by a user with the replicatio= n privilegelocal=C2=A0 =C2=A0 replication=C2=A0 =C2=A0 =C2=A0 all=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 trusthost=C2=A0 =C2=A0 replication=C2=A0 =C2=A0 =C2=A0= all=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 127..0.1/32=C2=A0 =C2=A0trusthost=C2= =A0 =C2=A0 replication=C2=A0 =C2=A0 =C2=A0 all=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ::1/128=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0trust the problem is I'm not sure I need to reconfigure pg_hba.conf with database= with user postgres or not? When I'm connecting into the each database and the "show pg_hba.conf" show = nothing. postgres-# show pg_hba.confpostgres-# =C2=A0Bach-Nga No one in this world is pure and perfect.=C2=A0 If you avoid people for the= ir mistakes you will be alone. So judge less, love and forgive more.To call= him a dog hardly seems to do him justice though in as much as he had four = legs, a tail, and barked, I admit he was, to all outward appearances. But t= o those who knew him well, he was a perfect gentleman (Hermione Gingold) **Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely = rich *** Faithful talent *** Sharing success=20 On Monday, February 25, 2019 12:28 PM, Shreeyansh Dba wrote: =20 Hi Pepe, It seems your are using os user for taking the backup. When you run command line commands against the postgres database and they a= sk for the user and password that is the database user postgres and its associated password, so when you do something like: psql -d templat= e1 -U postgres the password you will be prompted for is your_db_user passwo= rd=20 Now the above also depends on what is set in pg_hba.conf for the various co= mbinations of host, database, user and auth_method.=20 For more information see https://www.postgresql.org/docs/9.5/static/client-= authentication.html=20 Thanks & Regards, Shreeyansh DBA Team www.shreeyansh.com On Mon, Feb 25, 2019 at 10:21 PM Pepe TD Vo wrote: good morning Expert DBAs, I created a script to do backup and I have faced the error of=C2=A0 Performing globals backup:pg_dumpall: could not connect to database "templa= te1":FATAL: Ident authentication failed for user "postgres" fro globals bac= kup.=C2=A0 As same as performing schema-only backups and full backup. Performing schema-only backup:psql:FATAL: Ident authentication failed for u= ser "postgres"the following databases were matched for schema-only backup: performing full backup:psql:FATAL: Ident authentication failed for user "po= stgres" I can run pg_dumpall > postgresdump.sql as postgres user os but couldn't ru= n from script even the script declared BACKUP_USER=3Dpostgres If I take the syntax, -h "$HOSTNAME" -U "$USERNAME" out and the backup scri= pt working fine=C2=A0 # vi pg_backup.config############################## ## POSTGRESQL BACKUP CONFIG ## ############################## =C2=A0 # Optional system user to run backups as. If the user the script is runnin= g as doesn't match this # the script terminates. Leave blank to skip check. BACKUP_USER=3D =C2=A0 # Optional hostname to adhere to pg_hba policies. Will default to "localho= st" if none specified. HOSTNAME=3D"hostname" =C2=A0 # Optional username to connect to database as. Will default to "postgres" = if none specified. USERNAME=3D"postgres" =C2=A0 # This dir will be created if it doesn't exist. This must be writable by t= he user the script is # running as. BACKUP_DIR=3D/home/backups/database/postgresql/ =C2=A0 # List of strings to match against in database name, separated by space or = comma, for which we only # wish to keep a backup of the schema, not the data. Any database names whi= ch contain any of these # values will be considered candidates. (e.g. "system_log" will match "dev_= system_log_2010-01") SCHEMA_ONLY_LIST=3D"" =C2=A0 # Will produce a custom-format backup if set to "yes" ENABLE_CUSTOM_BACKUPS=3Dyes =C2=A0 # Will produce a gzipped plain-format backup if set to "yes" ENABLE_PLAIN_BACKUPS=3Dyes =C2=A0 # Will produce gzipped sql file containing the cluster globals, like users = and passwords, if set to "yes" ENABLE_GLOBALS_BACKUPS=3Dyes =C2=A0 =C2=A0 #### SETTINGS FOR ROTATED BACKUPS #### =C2=A0 # Which day to take the weekly backup from (1-7 =3D Monday-Sunday) DAY_OF_WEEK_TO_KEEP=3D5 =C2=A0 # Number of days to keep daily backups DAYS_TO_KEEP=3D7 =C2=A0 # How many weeks to keep weekly backups WEEKS_TO_KEEP=3D5 =C2=A0 ###################################### #vi pg_backup.sh#!/bin/bash########################### ####### LOAD CONFIG ####### ########################### =C2=A0 while [ $# -gt 0 ]; do case $1 in -c) if [ -r "$2" ]; then source "$2" shift 2 else ${ECHO} "Unreadable config file \"$2\"" 1>&= 2 exit 1 fi ;; *) ${ECHO} "Unknown Option \"$1\"" 1>&2 exit 2 ;; esac done =C2=A0 if [ $# =3D 0 ]; then SCRIPTPATH=3D$(cd ${0%/*} && pwd -P) source $SCRIPTPATH/pg_backup.config fi; =C2=A0 ########################### #### PRE-BACKUP CHECKS #### ########################### =C2=A0 # Make sure we're running as the required backup user if [ "$BACKUP_USER" !=3D "" -a "$(id -un)" !=3D "$BACKUP_USER" ]; then =09echo "This script must be run as $BACKUP_USER. Exiting." 1>&2 =09exit 1; fi; =C2=A0 =C2=A0 ########################### ### INITIALISE DEFAULTS ### ########################### =C2=A0 if [ ! $HOSTNAME ]; then =09HOSTNAME=3D"localhost" fi; =C2=A0 if [ ! $USERNAME ]; then =09USERNAME=3D"postgres" fi; =C2=A0 =C2=A0 ########################### #### START THE BACKUPS #### ########################### =C2=A0 =C2=A0 FINAL_BACKUP_DIR=3D$BACKUP_DIR"`date +\%Y-\%m-\%d`/" =C2=A0 echo "Making backup directory in $FINAL_BACKUP_DIR" =C2=A0 if ! mkdir -p $FINAL_BACKUP_DIR; then =09echo "Cannot create backup directory in $FINAL_BACKUP_DIR. Go and fix it= !" 1>&2 =09exit 1; fi; =C2=A0 =C2=A0 ####################### ### GLOBALS BACKUPS ### ####################### =C2=A0 echo -e "\n\nPerforming globals backup" echo -e "--------------------------------------------\n" =C2=A0 if [ $ENABLE_GLOBALS_BACKUPS =3D "yes" ] then echo "Globals backup" =C2=A0 if ! pg_dumpall -g -h "$HOSTNAME" -U "$USERNAME" | gzip > $FINAL_BA= CKUP_DIR"globals".sql.gz.in_progress; then echo "[!!ERROR!!] Failed to produce globals backup" 1>&2 else mv $FINAL_BACKUP_DIR"globals".sql.gz.in_progress $FINAL_BAC= KUP_DIR"globals".sql.gz fi else =09echo "None" fi =C2=A0 =C2=A0 ########################### ### SCHEMA-ONLY BACKUPS ### ########################### =C2=A0 for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } do =09SCHEMA_ONLY_CLAUSE=3D"$SCHEMA_ONLY_CLAUSE or datname ~ '$SCHEMA_ONLY_DB'= " done =C2=A0 SCHEMA_ONLY_QUERY=3D"select datname from pg_database where false $SCHEMA_ON= LY_CLAUSE order by datname;" =C2=A0 echo -e "\n\nPerforming schema-only backups" echo -e "--------------------------------------------\n" =C2=A0 SCHEMA_ONLY_DB_LIST=3D`psql -h "$HOSTNAME" -U "$USERNAME" -At -c "$SCHEMA_O= NLY_QUERY" postgres` =C2=A0 echo -e "The following databases were matched for schema-only backup:\n${SC= HEMA_ONLY_DB_LIST}\n" =C2=A0 for DATABASE in $SCHEMA_ONLY_DB_LIST do =09echo "Schema-only backup of $DATABASE" =C2=A0 =09if ! pg_dump -Fp -s -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | gzip > $= FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz.in_progress; then =09=09echo "[!!ERROR!!] Failed to backup database schema of $DATABASE" 1>&2 =09else =09=09mv $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz.in_progress $FINAL_BACK= UP_DIR"$DATABASE"_SCHEMA.sql.gz =09fi done =C2=A0 =C2=A0 ########################### ###### FULL BACKUPS ####### ########################### =C2=A0 for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } do =09EXCLUDE_SCHEMA_ONLY_CLAUSE=3D"$EXCLUDE_SCHEMA_ONLY_CLAUSE and datname=C2= =A0!~ '$SCHEMA_ONLY_DB'" done =C2=A0 FULL_BACKUP_QUERY=3D"select datname from pg_database where not datistemplat= e and datallowconn $EXCLUDE_SCHEMA_ONLY_CLAUSE order by datname;" =C2=A0 echo -e "\n\nPerforming full backups" echo -e "--------------------------------------------\n" =C2=A0 for DATABASE in `psql -h "$HOSTNAME" -U "$USERNAME" -At -c "$FULL_BACKUP_QU= ERY" postgres` do =09if [ $ENABLE_PLAIN_BACKUPS =3D "yes" ] =09then =09=09echo "Plain backup of $DATABASE" =C2=A0 =09=09if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | gzip > $= FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then =09=09=09echo "[!!ERROR!!] Failed to produce plain backup database $DATABAS= E" 1>&2 =09=09else =09=09=09mv $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress $FINAL_BACKUP_D= IR"$DATABASE".sql.gz =09=09fi =09fi =C2=A0 =09if [ $ENABLE_CUSTOM_BACKUPS =3D "yes" ] =09then =09=09echo "Custom backup of $DATABASE" =C2=A0 =09=09if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f $FINAL_= BACKUP_DIR"$DATABASE".custom.in_progress; then =09=09=09echo "[!!ERROR!!] Failed to produce custom backup database $DATABA= SE" 1>&2 =09=09else =09=09=09mv $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress $FINAL_BACKUP_D= IR"$DATABASE".custom =09=09fi =09fi =C2=A0 done =C2=A0 echo -e "\nAll database backups complete!" I'm appreciate if anyone know how to correct this? thank you. v/r,=C2=A0Bach-Nga No one in this world is pure and perfect.=C2=A0 If you avoid people for the= ir mistakes you will be alone. So judge less, love and forgive more.To call= him a dog hardly seems to do him justice though in as much as he had four = legs, a tail, and barked, I admit he was, to all outward appearances. But t= o those who knew him well, he was a perfect gentleman (Hermione Gingold) **Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely = rich *** Faithful talent *** Sharing success =20 ------=_Part_4989149_1286135336.1551120503711 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thank you for your information. 
I saw this document this morning and I did check my p= g_hba.conf and for local host and tried to connect to the template1/0 and/o= r other database with postgres fine without prompting me for the password&n= bsp;
#psql -d template0 -U = postgres
template0-#
#psq= l -d template1 -U postgres
template1-#
#psql -d CIDR = -U postgres
CIDR-#
#psql -d postgres -U postgres
postgres-#

and a pg_hba.conf:

"
#TYPE  DATABASE     USER     ADDR= ESS     METHOD
local     all            =      all              &nb= sp;              trust
host     all    &= nbsp;            all      &nbs= p;  127.0.0.1/32 trust
host     all            &nb= sp;    all         ::1/128    =      trust

#allo replication connections from local= host, by a user with the replication privilege
local    replication =     all                &= nbsp;             trust
host    replication=       all          127..0.1/32 = ;  trust
host    replication      all    &n= bsp;     ::1/128         trust


the problem is I'm not = sure I need to reconfigure pg_hba.conf with database with user postgres or = not?
When I= 'm connecting into the each database and the "show pg_hba.conf" show nothin= g.

<= /div>
postgres= -# show pg_hba.conf
postgres-#
 
Bach-Ng= a

No one in this world is pure and= perfect.  If you avoid people for their mistakes you will be alone. S= o judge less, love and forgive more.
To call him a= dog hardly seems to do him justice though in as much as he had four legs, = a tail, and barked, I admit he was, to all outward appearances. But to thos= e who knew him well, he was a perfect gentleman (Hermione Gingold)

**Live simply **Love generous= ly **Care deeply **Speak kindly.
*** Genuinely rich *** Fait= hful talent *** Sharing success


On Monday, February 25, 2019 12:28 PM, Shree= yansh Dba <shreeyansh2014@gmail.com> wrote:

Hi Pepe,

It seems you= r are using os user for taking the backup.

When you run c= ommand line commands against the postgres database and they ask for the use= r and password that is the database user postgres
and its= associated password, so when you do something like: psql -d template1 -U p= ostgres the password you will be prompted for is your_db_user password
Now the above also depends on what is set in pg_hba.conf for= the various combinations of host, database, user and auth_method.


=
Thanks & Regards,
Shreeyansh DBA Team
www.shreeyansh.com
<= /div>


On Mon, Feb 25, 2019 at 10:21= PM Pepe TD Vo <pepevo@ya= hoo.com> wrote:
good morning E= xpert DBAs,

I created a scr= ipt to do backup and I have faced the error of 

Performing globals backup:
pg_dumpa= ll: could not connect to database "template1":FATAL: Ident authentication f= ailed for user "postgres" fro globals backup.  As same as performing s= chema-only backups and full backup.

Performing schema-only backup:
psql:FATAL: Ident authentication failed for user "postgres"<= /div>
the following databases were matched for schema-on= ly backup:

performing full backup:
psql:FATAL: Ident authent= ication failed for user "postgres"

I can run= pg_dumpall > postgresdump.sql as postgres user os but couldn't run from= script even the script declared BACKUP_USER=3Dpostgres
<= /div>


If I take the syntax, -h "$HOSTNAME= " -U "$USERNAME" out and the backup script working fine 

# vi pg_backup.config
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
 
# Optional system user to run backups as.  If the user th=
e script is running as doesn't match this
# the script terminates.  Leave blank to skip check.
BACKUP_USER=3D
 
# Optional hostname to adhere to pg_hba policies.  Will d=
efault to "localhost" if none specified.
HOSTNAME=3D"hostname"
 
# Optional username to connect to database as.  Will defa=
ult to "postgres" if none specified.
USERNAME=3D"postgres"
 
# This dir will be created if it doesn't exist.  This mus=
t be writable by the user the script is
# running as.
BACKUP_DIR=3D/home/backups/database/postgresql/
 
# List of strings to match against in database name, sepa=
rated by space or comma, for which we only
# wish to keep a backup of the schema, not the data. Any =
database names which contain any of these
# values will be considered candidates. (e.g. "system_log=
" will match "dev_system_log_2010-01")
SCHEMA_ONLY_LIST=3D""
 
# Will produce a custom-format backup if set to "yes"
ENABLE_CUSTOM_BACKUPS=3Dyes
 
# Will produce a gzipped plain-format backup if set to "y=
es"
ENABLE_PLAIN_BACKUPS=3Dyes
 
# Will produce gzipped sql file containing the cluster gl=
obals, like users and passwords, if set to "yes"
ENABLE_GLOBALS_BACKUPS=3Dyes
 
 
#### SETTINGS FOR ROTATED BACKUPS ####
 
# Which day to take the weekly backup from (1-7 =3D Monda=
y-Sunday)
DAY_OF_WEEK_TO_KEEP=3D5
 
# Number of days to keep daily backups
DAYS_TO_KEEP=3D7
 
# How many weeks to keep weekly backups
WEEKS_TO_KEEP=3D5
 
######################################

#vi pg=
_backup.sh
#!/bin/bash
<= pre id=3D"yiv0716767970gmail-m_-6360316857236990950yui_3_16_0_ym19_1_155109= 7740995_250055">########################### ####### LOAD CONFIG ####### ###########################   while [ $# -gt 0 ]; do case $1 in -c) if [ -r "$2" ]; then source "$2" shift 2 else ${ECHO} "Unreadable config file \"$2\"" 1>&am= p;2 exit 1 fi ;; *) ${ECHO} = "Unknown Option \"$1\"" 1>&2 exit 2 ;; esac done   if [ $#= =3D 0 ]; then SCRIPTPATH=3D$(cd ${0%/*} pwd -P) source $SCRIPTPATH/pg_backup.config fi;   ########################### #### PRE-BACKUP CHECKS #### ###########################   # Make sure we're running as the required backup user if [ "<= span id=3D"yiv0716767970gmail-m_-6360316857236990950yui_3_16_0_ym19_1_15510= 97740995_250131">$BACKUP_USER" !=3D = "" -a "= $(id -un)" !=3D "$BACKUP_USER" ]; then =09echo "This script must be run= as $BACKUP_USER. Exiting." 1>&2 =09exit 1; fi;     ########################### ### INITIALISE DEFAULTS ### ###########################   if [ !<= /span> $HOSTNAME ]; then =09HOSTNAME=3D"localhost" fi;   if [ !<= /span> $USERNAME ]; then =09USERNAME=3D"postgres" fi;     ########################### #### START THE BACKUPS #### ###########################     FINAL_BACKUP_DIR=3D$BACKUP_DIR"`date +\%Y-\%m-\%d`/"   echo "Making backup directory in= $FINAL_BACKUP_DIR"   if ! mk= dir -p $FINAL_BACKUP_DIR<= /span>; then =09echo "Cannot create backup di= rectory in $FINAL_BACKUP_DIR. Go and fix it!" 1>&2 =09exit 1; fi;     ####################### ### GLOBALS BACKUPS ### #######################   echo -e "\n\nPerforming globals = backup" echo -e "--------------------------------------------\n"<= /span>   if [ $E= NABLE_GLOBALS_BACKUPS =3D "yes" ] then echo "Globals backup"   if ! pg_dumpall <= span id=3D"yiv0716767970gmail-m_-6360316857236990950yui_3_16_0_ym19_1_15510= 97740995_250219">-g -h "<= span id=3D"yiv0716767970gmail-m_-6360316857236990950yui_3_16_0_ym19_1_15510= 97740995_250222">$HOSTNAME" -U "$USERNAME" = | gzip > $FINAL_BACKUP_DIR"globals".sql.= gz.in_progress; then echo "[!!ERROR!!= ] Failed to produce globals backup" 1>&2 else mv $FINAL_BACKUP= _DIR"globals".sql.gz.in_progress $FINAL_BACKUP_DIR"globals".sql.gz fi else =09echo "None" fi     ########################### ### SCHEMA-ONLY BACKUPS ### ###########################   for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } do =09SCHEMA_ONLY_CLAUSE=3D"$SCHEMA_ONLY_CLAUSE or datname ~ '$SCHE= MA_ONLY_DB'" done   SCHEMA_ONLY_QUERY=3D"select datn= ame from pg_database where false $SCHEMA_ONLY_CLAUSE order by datname;"   echo -e "\n\nPerforming schema-o= nly backups" echo -e "--------------------------------------------\n"<= /span>   SCHEMA_ONLY_DB_LIST=3D`ps= ql -h "$HOSTNA= ME" -U "$USERNAME" -At -c "$SCHEMA_ONLY_QUERY" postgres`   echo -e "The following databases were matched for schema-only backup:\n${SCHEMA_ONLY_DB_LIST}\n"   for DATABASE in $SCHEMA_ONLY_DB_LIST do =09echo "Schema-only backup of <= span id=3D"yiv0716767970gmail-m_-6360316857236990950yui_3_16_0_ym19_1_15510= 97740995_250297">$DATABASE"   =09if ! pg_dump -Fp -s -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | gzip > $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz.in_progress; then =09=09echo "[!!ERROR!!] Failed t= o backup database schema of $DATABASE" 1>&2= =09else =09=09mv $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.g= z.in_progress $FINAL_BACKUP_DIR"= $DATABASE"_SCHEMA.sql.gz =09fi done     ########################### ###### FULL BACKUPS ####### ###########################   for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } do =09EXCLUDE_SCHEMA_ONLY_CLAUSE=3D= "$EXCLUDE_SCHEMA_ONLY_CLAUSE and datname !~ '= $SCHEMA_ONLY_DB'" done   FULL_BACKUP_QUERY=3D"select datn= ame from pg_database where not datistemplate and datallowconn $EXCLUDE_SCHEMA_ONLY_CLAUSE order by datname;"   echo -e "\n\nPerforming full bac= kups" echo -e "--------------------------------------------\n"<= /span>   for DATABASE in `psql -h "$HOSTNAME" -U "$USERNAME" -At= -c "$F= ULL_BACKUP_QUERY" postgres` do =09if [ $ENABLE_PLAIN_BACKUPS =3D "yes" ] =09then =09=09echo "Plain backup of $DATABASE"   =09=09if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | gzip > $FIN= AL_BACKUP_DIR"$DATABASE"<= /span>.sql.gz.in_progress; then =09=09=09echo "[!!ERROR!!] Faile= d to produce plain backup database $DATABASE" 1>&2 =09=09else =09=09=09mv $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in= _progress $FINAL_BACKUP_DIR"$DATABASE".sql.gz =09=09fi =09fi   =09if [ $ENABLE_CUSTOM_BACKUPS =3D "yes" ] =09then =09=09echo "Custom backup of $DATABASE"   =09=09if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f $FINAL_BACKUP_DIR"$D= ATABASE".custom.in_progress; then =09=09=09echo "[!!ERROR!!] Faile= d to produce custom backup database $DATABASE" 1>&2 =09=09else =09=09=09mv $FINAL_BACKUP_DIR"$DATABASE".custom.in= _progress $FINAL_BACKUP_DIR"$DATABASE".custom =09=09fi =09fi   done   echo -e "\nAll database backups complete!"

I'm appreciate if anyone kno= w how to correct this?

thank you.

v/r,
Bach-Nga

No one in= this world is pure and perfect.  If you avoid people for their mistak= es you will be alone. So judge less, love and forgive more.
To call him a dog hardly seems to do him j= ustice though in as much as he had four legs, a tail, and barked, I admit h= e was, to all outward appearances. But to those who knew him well, he was a= perfect gentleman (Hermione Gingold)

**Live simply **L= ove generously **Care deeply **Speak kindly.
*** Genuinely rich *** Faithful t= alent *** Sharing success


= ------=_Part_4989149_1286135336.1551120503711--