Re: migrating to 9.2 created blank dbs - Mailing list pgsql-admin

From Marc Fromm
Subject Re: migrating to 9.2 created blank dbs
Date
Msg-id SN1PR0201MB1566E329F9C367E68E69823A9DD20@SN1PR0201MB1566.namprd02.prod.outlook.com
Whole thread Raw
In response to Re: migrating to 9.2 created blank dbs  (Jeff Frost <jeff@pgexperts.com>)
List pgsql-admin
Jeff's recommendation of changing how the script gets a list of databases solved the blank database backups called
"|".

Thanks for everyone's responses.

Marc

-----Original Message-----
From: Jeff Frost [mailto:jeff@pgexperts.com] 
Sent: Monday, May 04, 2015 10:29 AM
To: Marc Fromm
Cc: Tom Lane; Keith; Raghavendra; Keith Fiske; pgsql-admin@postgresql.org
Subject: Re: [ADMIN] migrating to 9.2 created blank dbs

So, you want to change this line:

databases=`psql -h localhost -U postgres -q -c "\l" | sed -n 4,/\eof/p | grep -v rows\) | awk {'print $1’}`

to this:

psql -h localhost -U postgres -q --tuples-only --no-align -c "SELECT datname from pg_database”



> On May 4, 2015, at 10:14 AM, Marc Fromm <Marc.Fromm@wwu.edu> wrote:
> 
> It has been suggested that I am misinterpreting the verbose output, which is very possible. Is the problem then with
mybackup script that works fine in 8.1 but needs a tweak to ignore whatever is triggering the attempt to create a
backupcalled "|"?
 
> 
> It appears that only after databases with the extra stuff at the end is when a file is created called "|"
> 
> Databases (/l command):
> manuals                 | postgres | LATIN1    | C       | C     | =CTc/postgres        +
>                             |          |           |         |       |                       postgres=CT/postgres
> marctestdb          | postgres | SQL_ASCII | C       | C     |
> mattdb                  | postgres | SQL_ASCII | C       | C     |
> mydb                      | postgres | SQL_ASCII | C       | C     | =Tc/postgres         +
>                                 |          |           |         |       |               postgres=CT/postgres
> nasfaa                  | postgres | SQL_ASCII | C       | C     |
> 
> Backup log:
> Backup and Vacuum complete at 13:21:09-2015-05-01 for time slot 
> 05-01-2015_13-21 on database: manuals Backup and Vacuum complete at 
> 13:21:09-2015-05-01 for time slot 05-01-2015_13-21 on database: | 
> Backup and Vacuum complete at 13:21:09-2015-05-01 for time slot 
> 05-01-2015_13-21 on database: marctestdb Backup and Vacuum complete at 
> 13:21:09-2015-05-01 for time slot 05-01-2015_13-21 on database: mattdb 
> Backup and Vacuum complete at 13:21:10-2015-05-01 for time slot 
> 05-01-2015_13-21 on database: mydb Backup and Vacuum complete at 
> 13:21:10-2015-05-01 for time slot 05-01-2015_13-21 on database: | 
> Backup and Vacuum complete at 13:21:10-2015-05-01 for time slot 
> 05-01-2015_13-21 on database: nasfaa
> 
> Script:
> #!/bin/bash
> # Location of the backup logfile.
> logfile="/var/lib/pgsql/backups/logs/pg_back.log"
> # Location to place backups.
> backup_dir="/var/lib/pgsql/backups"
> touch $logfile
> timeslot=`date +%m-%d-%Y_%H-%M`
> databases=`psql -h localhost -U postgres -q -c "\l" | sed -n 4,/\eof/p 
> | grep -v rows\) | awk {'print $1'}`
> 
> for i in $databases; do
>   timeinfo=`date '+%T-%F'`
>   echo "Backup and Vacuum complete at $timeinfo for time slot $timeslot on database: $i " >> $logfile
>   /usr/bin/vacuumdb -z -h localhost -U postgres $i >/dev/null 2>&1
>   /usr/bin/pg_dump $i -ch 127.0.0.1 -U postgres | gzip > "$backup_dir/postgresql-$i-$timeslot-database.gz"
> Done
> 
> -----Original Message-----
> From: Jeff Frost [mailto:jeff@pgexperts.com]
> Sent: Monday, May 04, 2015 9:41 AM
> To: Marc Fromm
> Cc: Tom Lane; Keith; Raghavendra; Keith Fiske; 
> pgsql-admin@postgresql.org
> Subject: Re: [ADMIN] migrating to 9.2 created blank dbs
> 
> Any chance you’re just misinterpreting the new more verbose output of psql’s \l command?
> 
> Nowadays, it looks like this:
> 
> postgres=# \l
>                                List of databases
>     Name      |   Owner    | Encoding | Collate | Ctype |   Access privileges
> ---------------+------------+----------+---------+-------+------------
> ---------------+------------+----------+---------+-------+--
> ---------------+------------+----------+---------+-------+---------
> postgres      | postgres   | UTF8     | C       | C     |
> template0     | postgres   | UTF8     | C       | C     | =c/postgres          +
>               |            |          |         |       | postgres=CTc/postgres
> template1     | postgres   | UTF8     | C       | C     | =c/postgres          +
>               |            |          |         |       | postgres=CTc/postgres
> (4 rows)
> 
> But there are still only 3 databases being listed above.  
> 
>> On May 4, 2015, at 9:24 AM, Marc Fromm <Marc.Fromm@wwu.edu> wrote:
>> 
>> Running the select statement gives me a list of all my databases. The only thing that looks suspicious are a few
databaseshave stuff like this in the datacl column " {postgres=CT/postgres,=T/postgres}". The number of databases with
thatis suspiciously equal to the number of blanks created.
 
>> 
>> Marc
>> 
>> -----Original Message-----
>> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>> Sent: Monday, May 04, 2015 9:07 AM
>> To: Keith
>> Cc: Marc Fromm; Raghavendra; Keith Fiske; pgsql-admin@postgresql.org
>> Subject: Re: [ADMIN] migrating to 9.2 created blank dbs
>> 
>>> On Fri, May 1, 2015 at 6:39 PM, Marc Fromm <Marc.Fromm@wwu.edu> wrote:
>>>> I setup a server running postgresql-server-9.2.10-2.el7_1.x86_64. 
>>>> After restoring my databases form a system running
>>>> postgresql-server-8.1.23-10.el5_10 (created with pg_dumpall), 
>>>> several blank databases/entries were created.
>> 
>> FWIW, this seems to match a symptom we've heard of occasionally in which the source server's catalogs are corrupted.
If the 8.1 server is still online it would be interesting to connect to it manually and see what you get from "select *
frompg_database”.
 
> 
> 
> 
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make 
> changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin

---
Jeff Frost <jeff@pgexperts.com>
CTO, PostgreSQL Experts, Inc.
Phone: 1-888-PG-EXPRT x506
FAX: 415-762-5122
http://www.pgexperts.com/ 




pgsql-admin by date:

Previous
From: Jeff Frost
Date:
Subject: Re: migrating to 9.2 created blank dbs
Next
From: Jan Lentfer
Date:
Subject: Re: pg_dump and pg_restore with multiple streams does Not seem to improve overall times