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 1gyJWi-0003f6-RD for pgsql-admin@arkaria.postgresql.org; Mon, 25 Feb 2019 16:54:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyJWh-0006Io-CY for pgsql-admin@arkaria.postgresql.org; Mon, 25 Feb 2019 16:54:47 +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 1gyJWh-0006Ih-4r for pgsql-admin@lists.postgresql.org; Mon, 25 Feb 2019 16:54:47 +0000 Received: from imx6.etecsa.cu ([200.55.152.141]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gyJWd-0001YR-QI for pgsql-admin@postgresql.org; Mon, 25 Feb 2019 16:54:46 +0000 Received: from mail.etecsa.cu (unknown [192.168.91.10]) by imx6.etecsa.cu (Postfix) with ESMTP id 35FD1C4; Mon, 25 Feb 2019 11:54:39 -0500 (CST) Received: from webmailrc.etecsa.cu (unknown [192.168.97.37]) (Authenticated sender: gilberto.castillo) by mail.etecsa.cu (Postfix) with ESMTPA id 2CF2D329444F; Mon, 25 Feb 2019 11:54:39 -0500 (CST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 25 Feb 2019 11:54:39 -0500 From: gilberto.castillo@etecsa.cu To: Pepe TD Vo Cc: Pgsql-admin Subject: Re: [MASSMAIL]pg_dumpall: could not connect to database: FATAL In-Reply-To: <1323549085.4899214.1551113430643@mail.yahoo.com> References: <1323549085.4899214.1551113430643.ref@mail.yahoo.com> <1323549085.4899214.1551113430643@mail.yahoo.com> X-Priority: 1 (Highest) Message-ID: X-Sender: gilberto.castillo@etecsa.cu User-Agent: Roundcube Webmail/1.2.5 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 136189 [Feb 25 2019] X-KLMS-AntiSpam-Version: 5.8.6.0 X-KLMS-AntiSpam-Envelope-From: gilberto.castillo@etecsa.cu X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Info: LuaCore: 234 234 6084fb9491110ca2901942eb14874f7e6341a62a, Auth:dkim=none X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, 2019/02/22 13:40:30 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2019/02/25 07:56:00 #9397435 X-KLMS-AntiVirus-Status: Clean, skipped List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Pepe, Is there a user postgres in your database? Do you changer backup user? El 2019-02-25 11:50, Pepe TD Vo escribió: > good morning Expert DBAs, > > I created a script to do backup and I have faced the error of > >> Performing globals backup: >> pg_dumpall: could not connect to database "template1":FATAL: Ident >> authentication failed for user "postgres" fro globals backup. As >> same as performing schema-only backups and full backup. >> >> Performing schema-only backup: >> psql:FATAL: Ident authentication failed for user "postgres" >> the following databases were matched for schema-only backup: >> >> performing full backup: >> psql:FATAL: Ident authentication 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=postgres > > 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 the script is > running as doesn't match this > # the script terminates. Leave blank to skip check. > BACKUP_USER= > > # Optional hostname to adhere to pg_hba policies. Will default to > "localhost" if none specified. > HOSTNAME="hostname" > > # Optional username to connect to database as. Will default to > "postgres" if none specified. > USERNAME="postgres" > > # This dir will be created if it doesn't exist. This must be writable > by the user the script is > # running as. > BACKUP_DIR=/home/backups/database/postgresql/ > > # 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 which contain any of these > # values will be considered candidates. (e.g. "system_log" will match > "dev_system_log_2010-01") > SCHEMA_ONLY_LIST="" > > # Will produce a custom-format backup if set to "yes" > ENABLE_CUSTOM_BACKUPS=yes > > # Will produce a gzipped plain-format backup if set to "yes" > ENABLE_PLAIN_BACKUPS=yes > > # Will produce gzipped sql file containing the cluster globals, like > users and passwords, if set to "yes" > ENABLE_GLOBALS_BACKUPS=yes > > #### SETTINGS FOR ROTATED BACKUPS #### > > # Which day to take the weekly backup from (1-7 = Monday-Sunday) > DAY_OF_WEEK_TO_KEEP=5 > > # Number of days to keep daily backups > DAYS_TO_KEEP=7 > > # How many weeks to keep weekly backups > WEEKS_TO_KEEP=5 > > ###################################### > > #VI PG_BACKUP.SH > > #!/bin/bash > > ########################### > ####### 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>&2 > exit 1 > fi > ;; > *) > ${ECHO} "Unknown Option \"$1\"" 1>&2 > exit 2 > ;; > esac > done > > if [ $# = 0 ]; then > SCRIPTPATH=$(cd ${0%/*} && pwd -P) > source $SCRIPTPATH/pg_backup.config > fi; > > ########################### > #### PRE-BACKUP CHECKS #### > ########################### > > # Make sure we're running as the required backup user > if [ "$BACKUP_USER" != "" -a "$(id -un)" != "$BACKUP_USER" ]; then > echo "This script must be run as $BACKUP_USER. Exiting." 1>&2 > exit 1; > fi; > > ########################### > ### INITIALISE DEFAULTS ### > ########################### > > if [ ! $HOSTNAME ]; then > HOSTNAME="localhost" > fi; > > if [ ! $USERNAME ]; then > USERNAME="postgres" > fi; > > ########################### > #### START THE BACKUPS #### > ########################### > > FINAL_BACKUP_DIR=$BACKUP_DIR"`date +\%Y-\%m-\%d`/" > > echo "Making backup directory in $FINAL_BACKUP_DIR" > > if ! mkdir -p $FINAL_BACKUP_DIR; then > echo "Cannot create backup directory in $FINAL_BACKUP_DIR. Go and > fix it!" 1>&2 > exit 1; > fi; > > ####################### > ### GLOBALS BACKUPS ### > ####################### > > echo -e "\n\nPerforming globals backup" > echo -e "--------------------------------------------\n" > > if [ $ENABLE_GLOBALS_BACKUPS = "yes" ] > then > echo "Globals backup" > > if ! pg_dumpall -g -h "$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 > echo "None" > fi > > ########################### > ### SCHEMA-ONLY BACKUPS ### > ########################### > > for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } > do > SCHEMA_ONLY_CLAUSE="$SCHEMA_ONLY_CLAUSE or datname ~ > '$SCHEMA_ONLY_DB'" > done > > SCHEMA_ONLY_QUERY="select datname from pg_database where false > $SCHEMA_ONLY_CLAUSE order by datname;" > > echo -e "\n\nPerforming schema-only backups" > echo -e "--------------------------------------------\n" > > SCHEMA_ONLY_DB_LIST=`psql -h "$HOSTNAME" -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 > echo "Schema-only backup of $DATABASE" > > if ! pg_dump -Fp -s -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | > gzip > $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz.in_progress; then > echo "[!!ERROR!!] Failed to backup database schema of > $DATABASE" 1>&2 > else > mv $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz.in_progress > $FINAL_BACKUP_DIR"$DATABASE"_SCHEMA.sql.gz > fi > done > > ########################### > ###### FULL BACKUPS ####### > ########################### > > for SCHEMA_ONLY_DB in ${SCHEMA_ONLY_LIST//,/ } > do > EXCLUDE_SCHEMA_ONLY_CLAUSE="$EXCLUDE_SCHEMA_ONLY_CLAUSE and > datname !~ '$SCHEMA_ONLY_DB'" > done > > FULL_BACKUP_QUERY="select datname from pg_database where not > datistemplate and datallowconn $EXCLUDE_SCHEMA_ONLY_CLAUSE order by > datname;" > > echo -e "\n\nPerforming full backups" > echo -e "--------------------------------------------\n" > > for DATABASE in `psql -h "$HOSTNAME" -U "$USERNAME" -At -c > "$FULL_BACKUP_QUERY" postgres` > do > if [ $ENABLE_PLAIN_BACKUPS = "yes" ] > then > echo "Plain backup of $DATABASE" > > if ! pg_dump -Fp -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" | > gzip > $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress; then > echo "[!!ERROR!!] Failed to produce plain backup database > $DATABASE" 1>&2 > else > mv $FINAL_BACKUP_DIR"$DATABASE".sql.gz.in_progress > $FINAL_BACKUP_DIR"$DATABASE".sql.gz > fi > fi > > if [ $ENABLE_CUSTOM_BACKUPS = "yes" ] > then > echo "Custom backup of $DATABASE" > > if ! pg_dump -Fc -h "$HOSTNAME" -U "$USERNAME" "$DATABASE" -f > $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress; then > echo "[!!ERROR!!] Failed to produce custom backup database > $DATABASE" 1>&2 > else > mv $FINAL_BACKUP_DIR"$DATABASE".custom.in_progress > $FINAL_BACKUP_DIR"$DATABASE".custom > fi > fi > > done > > echo -e "\nAll database backups complete!" > > I'm appreciate if anyone know 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 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 to 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