Re: Shell Script help for backup

From: strange(at)nsk(dot)yi(dot)org
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Shell Script help for backup
Date: 2002-07-29 08:44:45
Message-ID: 20020729094445.B1866@nsk.yi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jul 28, 2002 at 11:22:22PM -0400, Bruce Momjian wrote:
>
> You can do 'zcat < file' to prevent the *.Z requirement. Yes, head -n
> should work fine.

Hm... I missed the other email, so I'm replying to this:

The "$( zcat /folder/pg_backup.$DATE.gzip | head -c1 | wc -c )" is to
check if there are any bytes stored in the gzip file.

If the zcat expects an .Z file, try with gzcat file, gzcat < file, or
gzip -d < file.

head -c1 is meant to stop the decompression at the first byte, I didn't
want it to wait until full decompression of the gzipped file, and I didn't
use -n because then it would depend on the internal format of the
decompressed file (if it was a binary file, a newline could appear only
after quite some time).

If you're going to use head -n1, then change the test to:
[ "$( gzip -d < /folder/pg_backup.$DATE.gzip | head -n1 | wc -c )" -ge 1 ]

(ie, instead of checking if bytes == 1, check if bytes >= 1).

Regards,
Luciano Rocha

--
Consciousness: that annoying time between naps.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Elielson Fontanezi 2002-07-29 11:34:50 RES: The best book
Previous Message Christopher Kings-Lynne 2002-07-29 07:06:05 Re: [GENERAL] Stats Collector