Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 452A42E003B for ; Mon, 19 May 2008 08:04:06 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 22595-06 for ; Mon, 19 May 2008 08:03:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web25803.mail.ukl.yahoo.com (web25803.mail.ukl.yahoo.com [217.12.10.188]) by developer.postgresql.org (Postfix) with SMTP id CB6E42E0031 for ; Mon, 19 May 2008 08:03:30 -0300 (ADT) Received: (qmail 61835 invoked by uid 60001); 19 May 2008 11:03:28 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.uk; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=wgIbzuB9wZJRwq9COETtVlmuD99e8fRVyKSyPvoRr9XM6KLre44PQsQR6emg3SSkaDaXCTsgvueocSS3zddBgBaYnkdrE+Kf9YC4Dk3IfKmBQ0MEnSEoFtuOW5G9SIJAtow2T7iv1SJDA/U3ppKMrGQ3HpIMbzxMJ904flX5nyM=; X-YMail-OSG: lS3ipqoVM1mSDrg18LSHR7AnqIYtgFVap4U0LRsXzBBo7gLwBTR_4n9fHFyZsyUWtw-- Received: from [83.166.184.142] by web25803.mail.ukl.yahoo.com via HTTP; Mon, 19 May 2008 11:03:28 GMT X-Mailer: YahooMailRC/975.41 YahooMailWebService/0.7.185 Date: Mon, 19 May 2008 11:03:28 +0000 (GMT) From: Glyn Astill Subject: Re: pg_restore test procedures (a bit OT) To: Phillip Smith , pgsql-admin@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Message-ID: <885828.61510.qm@web25803.mail.ukl.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/161 X-Sequence-Number: 29245 Thanks Phillip,=0A=0AI think the source of my problem was me being dumb and= only capturing stdout, rather than stderr and stdout! I needed the "2>&1" = on the end.=0A=0A=0A=0A=0A----- Original Message ----=0A> From: Phillip Smi= th =0A> To: Glyn Astill ; pgsql-admin@postgresql.org=0A> Sent: Monday, 19 May, 2008 1:05:03= AM=0A> Subject: Re: [ADMIN] pg_restore test procedures (a bit OT)=0A> =0A>= > I was just wondering if anyone has any clever way of testing their backu= ps=0A> taken with pg_dump on a daily basis?=0A> I have a daily bash script = to backup of one of my databases to file, then=0A> file to tape, which I te= st restore once per week. I've changed some of my=0A> variables to hard-cod= ed strings to make it shorter and easier to understand=0A> at a quick read.= Yes I know it's kinda fschked but it's working atm. I'll=0A> tidy it up ev= entually....=0A> =0A> =0A> if [ "$DAY" =3D "Mon" ] ; then=0A> echo "Tes= t restoring database..." >> $LOG_FILE=0A> =0A> if [ 1 -eq 1 ] ; then=0A= > # Debugging=0A> $ECHO "Restoring from: ${BACKUP= _PATH}"=0A> $ECHO "Restoring to Directory: ${TMPDNAME}"=0A> = $ECHO "Restore Database: ${DBNAME}${DATESTRING}"=0A> $EC= HO "Restore Source File: ${TMPFILE}"=0A> fi=0A> =0A> echo -n "= Extracting database dump from tape... "=0A> tar xf /dev/st0 --directory= /tmp=0A> if [ $? -ne 0 ] ; then=0A> echo "FAIL"=0A> ec= ho " Failed to Restore from /dev/st0 to /tmp/" >>=0A> $LOG_FILE=0A> = SHOW_ERR=3Dtrue=0A> fi=0A> =0A> if [ ${SHOW_ERR} !=3D true ] ; t= hen=0A> ### Note: $DATESTRING =3D yymmdd (eg. 080519)=0A> e= cho "Creating new database ${DBNAME}${DATESTRING}" >>=0A> $LOG_FILE=0A> = /usr/local/bin/psql --command "CREATE DATABASE=0A> ${DBNAME}${DATESTRI= NG} ENCODING =3D 'SQL_ASCII';" > /dev/null=0A> if [ $? -eq 0 ] ; th= en=0A> echo "Restoring /tmp/psqldump.sql.502 to=0A> ${DBNAME}${= DATESTRING}" >> $LOG_FILE=0A> /usr/local/bin/psql ${DBNAME}${DA= TESTRING} <=0A> /tmp/psqldump.sql.502=0A> else=0A> echo= "Failed to Create Database!" >> $LOG_FILE=0A> SHOW_ERR=3Dtrue= =0A> fi=0A> fi=0A> Fi=0A> =0A> =0A> > su - $PGUSER -c "pg_resto= re -h localhost -U postgres --disable-triggers -c=0A> -d $database $backup_= dir/$server-$database-data.gz" >> $logfile=0A> > or =0A> > su - $PGUSER -c = "pg_restore -h localhost -U postgres --disable-triggers -c=0A> -d $database= $backup_dir/$server-$database-data.gz >> $logfile"=0A> =0A> Perhaps someth= ing like this: (it's Monday morning, so I might be suggesting=0A> something= stupid)=0A> LOG=3D`su - $PGUSER -c "pg_restore -h localhost -U postgres --= disable-triggers=0A> -c -d $database $backup_dir/$server-$database-data.gz"= `=0A> echo $LOG >> $logfile=0A> =0A> =0A> THINK BEFORE YOU PRINT - Save pap= er if you don't really need to print this=0A> =0A> *******************Confi= dentiality and Privilege Notice*******************=0A> =0A> The material co= ntained in this message is privileged and confidential to=0A> the addressee= . If you are not the addressee indicated in this message or=0A> responsibl= e for delivery of the message to such person, you may not copy=0A> or deliv= er this message to anyone, and you should destroy it and kindly=0A> notify = the sender by reply email.=0A> =0A> Information in this message that does n= ot relate to the official business=0A> of Weatherbeeta must be treated as n= either given nor endorsed by Weatherbeeta.=0A> Weatherbeeta, its employees,= contractors or associates shall not be liable=0A> for direct, indirect or = consequential loss arising from transmission of this=0A> message or any att= achments=0A> e-mail.=0A> =0A> -- =0A> Sent via pgsql-admin mailing list (pg= sql-admin@postgresql.org)=0A> To make changes to your subscription:=0A> htt= p://www.postgresql.org/mailpref/pgsql-admin=0A=0A=0A=0A ______________= ____________________________________________=0ASent from Yahoo! Mail.=0AA S= marter Email http://uk.docs.yahoo.com/nowyoucan.html