Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2EF3D1014388 for ; Thu, 1 Mar 2012 06:16:45 -0400 (AST) Received: from eu1sys200aog107.obsmtp.com ([207.126.144.123]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1S333x-0005VZ-1V for pgsql-admin@postgresql.org; Thu, 01 Mar 2012 10:16:44 +0000 Received: from mail-iy0-f172.google.com ([209.85.210.172]) (using TLSv1) by eu1sys200aob107.postini.com ([207.126.147.11]) with SMTP ID DSNKT09Me9oUHNlU97XVZl5x7Oi+Ok15MCN/@postini.com; Thu, 01 Mar 2012 10:16:40 UTC Received: by mail-iy0-f172.google.com with SMTP id z13so900313iaz.17 for ; Thu, 01 Mar 2012 02:16:27 -0800 (PST) Received-SPF: pass (google.com: domain of kgama@argility.com designates 10.50.158.131 as permitted sender) client-ip=10.50.158.131; Authentication-Results: mr.google.com; spf=pass (google.com: domain of kgama@argility.com designates 10.50.158.131 as permitted sender) smtp.mail=kgama@argility.com Received: from mr.google.com ([10.50.158.131]) by 10.50.158.131 with SMTP id wu3mr3824211igb.49.1330596987825 (num_hops = 1); Thu, 01 Mar 2012 02:16:27 -0800 (PST) Received: by 10.50.158.131 with SMTP id wu3mr3144079igb.49.1330596987715; Thu, 01 Mar 2012 02:16:27 -0800 (PST) From: Khangelani Gama References: <539e85fb02376a0adb1ab5eb6e833cb3@mail.gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQDqWPzZXVWFK+PuJs3uqVNT0unhEgJv0ADSmAb361A= Date: Thu, 1 Mar 2012 12:16:54 +0200 Message-ID: Subject: Re: Can't recover data from a .tar.gz file which was backed up using COPY BINARY command To: Matheus de Oliveira Cc: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=14dae934037dcac11704ba2bc0e5 X-Gm-Message-State: ALoCoQmaTlt0+4SRTRYq6plJ2y7rtdKcTbUhwZ0zPDKaDoWU7SxdLTdPDT6lW8A0ij1dRuz9G8Wh X-Pg-Spam-Score: -4.2 (----) X-Archive-Number: 201203/4 X-Sequence-Number: 39192 --14dae934037dcac11704ba2bc0e5 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi Matheus I get the following error when trying your command: ERROR: COPY BINARY: file signature not recognized *From:* Matheus de Oliveira [mailto:matioli.matheus@gmail.com] *Sent:* Thursday, March 01, 2012 11:56 AM *To:* Khangelani Gama *Cc:* pgsql-admin@postgresql.org *Subject:* Re: [ADMIN] Can't recover data from a .tar.gz file which was backed up using COPY BINARY command Have you tried the above? COPY BINARY dailybackup FROM If so, what happened? -- Matheus de Oliveira Bacharelado em Ci=EAncias de Computa=E7=E3o Laborat=F3rio de Computa=E7=E3o de Alto Desempenho - LCAD Instituto de Ci=EAncias Matem=E1ticas e de Computa=E7=E3o - ICMC Universidade de S=E3o Paulo - USP On Thu, Mar 1, 2012 at 4:51 AM, Khangelani Gama wrote: Someone in our company wrote a script that backs up data from a certain table, that person left the company and no one is able to figure it out. Part of this script has something like, look at the COPY BINARY command just below: EXPORTFILE=3D${EXPORTFILE}.${AUD_UP_TO}_${MAX_AUDIT} *$PSQL -c "COPY BINARY dailybackup TO '$EF_PATH/$EXPORTFILE';"* if [ $? -eq 0 ]; then cd $EF_PATH tar cvzf ${EXPORTFILE}.tar.gz ${EXPORTFILE} if [ $? -ne 0 ]; then echo -e "Error while compressing tar file : " > /tmp/backup.trickle.state echo `date` >> /tmp/backup.trickle.state fi echo "Backup to backup disk successful" echo "Update trickle checkpoint" ${ANT} run -Dclass=3Ducs.instore.ejb.system.SetTrickleCheckpoint -Darg1=3D${MAX_AUDIT} I tried to untar the file which went through fine, but now inside the file there is funny characters, see below: PGBCOPY =FF^M ^@^D^C^B^A^@^@^@^@^@^@^@^@^R^@^D^@~UIS^@=FF=FF ^@^@^@1~1~1^D^@^=C9^@^@^D^@^@^@^@^@=FF=FF^K^@^@^@day_end=FF=FF^K^@^@^@centr= al^H^@wI=F4=F0=E5=CF=B6A=FF=FF=B6^B^@^@^M I am aware of the following format, but can=92t figure out how many characters should I specify and this backup system doesn=92t use pg_dump command? COPY [ BINARY ] table_name [ WITH OIDS ] FROM { 'filename' | STDIN } [ [USING] DELIMITERS 'delimiter' ] [ WITH NULL AS 'null string' ] Thanks in advanced CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited. If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes. CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addre= ssee only, and may contain the confidential information of Argility (Prop= rietary) Limited and/or its subsidiaries. Any review, use or disseminatio= n thereof by anyone other than the intended addressee is prohibited. If you are not the intended addressee please notify the writer immediatel= y and destroy the e-mail. Argility (Proprietary) Limited and its subsidia= ries distance themselves from and accept no liability for unauthorised us= e of their e-mail facilities or e-mails sent other than strictly for busi= ness purposes. =0D --14dae934037dcac11704ba2bc0e5 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

Hi= Matheus

=A0

I get the following error when tryin= g your command:

=A0

ERROR:=A0 COPY BINARY: file signature = not recognized

=A0

=A0

=A0

From: Matheus de Oliveira= [mailto:matioli.matheus@gmail= .com]
Sent: Thursday, March 01, 2012 11:56 AM
To: Khangelani Gam= a
Cc: pgsql-admin@p= ostgresql.org
Subject: Re: [ADMIN] Can't recover data fro= m a .tar.gz file which was backed up using COPY BINARY command

=A0

Have you tried the above?

COPY BINARY dailybackup FROM <uncompressed file>

If so, what happened?

--
Matheus de Oliveira

Bacharela= do em Ci=EAncias de Computa=E7=E3o
Laborat=F3rio de Computa=E7=E3o de Alto Desempenho - = LCAD
Instituto de Ci=EAnci= as Matem=E1ticas e de Computa=E7=E3o - ICMC
Universidade de S=E3o Paulo - USP


On Thu, Mar 1, 2012 at 4:51 AM, Khangelani Gama <= kgama@argility.com<= /a>> wrote:

Someone in our company wrote a script that backs up data from a= certain table, that person left the company and no one is able to figure i= t out. Part of this script has something like, look at the COPY BINARY comm= and just below:

=A0

EXPORTFILE=3D${EXPORTFILE}.${AUD_UP_TO}_${MAX_AU= DIT}

=A0=A0 $PSQL -c "COPY BINARY d= ailybackup TO '$EF_PATH/$EXPORTFILE';"

=A0

=A0=A0 if = [ $? -eq 0 ]; then

=A0=A0=A0=A0=A0 cd $EF_P= ATH

=A0=A0=A0=A0=A0 tar cvzf ${EXPORTFILE}.= tar.gz ${EXPORTFILE}

=A0=A0=A0=A0=A0 if [ $? -ne 0 ]; then

=A0= =A0=A0=A0=A0=A0=A0=A0 echo -e "Error while compressing tar file :=A0 &= quot; > /tmp/backup.trickle.state

=A0=A0= =A0=A0=A0=A0=A0=A0 echo `date` >> /tmp/backup.trickle.state

=A0

fi

=A0

=A0=A0 echo "Backup to backup disk successful"

<= p class=3D"MsoNormal" style> =A0

=A0=A0 echo "Update trickle checkp= oint"

=A0=A0 =A0

=A0=A0 ${ANT} run -Dclass=3Ducs.instore.ejb.system.SetTrickleChe= ckpoint -Darg1=3D${MAX_AUDIT}

=A0

=A0

=A0

I tried to untar the file which went through = fine, but now inside the file there is funny characters, see below:<= /p>

=A0

PGBCOPY

=FF^M

^@^D^C^B^A^@^@^@^@^@^@^@^@^R^@^D^@~UIS^@=FF=FF=A0=A0=A0= =A0=A0 ^@^@^@1~1~1^D^@^=C9^@^@^D^@^@^@^@^@=FF=FF^K^@^@^@day_end=FF=FF^K^@^@= ^@central^H^@wI=F4=F0=E5=CF=B6A=FF=FF=B6^B^@^@<?xml version=3D"1.0&= quot; encoding=3D"UTF-8"?>^M

=A0

=A0

I am aware of the following f= ormat, but can=92t figure out how many characters should I specify and this= backup system doesn=92t use pg_dump command?

=A0

=A0

COPY [ BINARY ] table_name [ WITH OIDS ]

=A0=A0=A0 FROM { 'filename' | STDIN }=

=A0=A0=A0 [ [USING] DELIMITERS 'delimiter= 9; ]

=A0=A0=A0 [ WITH NULL AS 'null string' ]

=A0

=A0

=A0

Thanks in advanced

=A0

=A0

=A0

CONFIDENTIALITY NOTICE
The contents of and attachme=
nts to this e-mail are intended for the addressee only, and may contain the=
 confidential information of Argility (Proprietary) Limited and/or its subs=
idiaries. Any review, use or dissemination thereof by anyone other than the=
 intended addressee is prohibited.
If you are not the intended addressee please notify the writer immedia=
tely and destroy the e-mail. Argility (Proprietary) Limited and its subsidi=
aries distance themselves from and accept no liability for unauthorised use=
 of their e-mail facilities or e-mails sent other than strictly for busines=
s purposes.
=A0

=A0




CONFIDENTIALITY NOTICE
The contents of and attachments to this e-mail are intended for the addre=
ssee only, and may contain the confidential information of Argility (Prop=
rietary) Limited and/or its subsidiaries. Any review, use or disseminatio=
n thereof by anyone other than the intended addressee is prohibited.
If you are not the intended addressee please notify the writer immediatel=
y and destroy the e-mail. Argility (Proprietary) Limited and its subsidia=
ries distance themselves from and accept no liability for unauthorised us=
e of their e-mail facilities or e-mails sent other than strictly for busi=
ness purposes.
=0D
--14dae934037dcac11704ba2bc0e5--