PostgreSQL backup + gzip

Posted on

Question :

We have a need to send PostgreSQL DB backup to CRM developer.
We send them and get feedback that the backup can’t be “uzipped”, as archive is broken.

The backup script snippet looks like this:

pg_dump -c -O -U postgres $x -h localhost -p 5432 --disable-dollar-quoting -i | gzip > $BACKUPDIR/$DT-$x.gz

We chceck the backup process and in our opinion there is no any issue with backuping system.

btw. They used 7Zip to unzip.

Question: What would you suggest to me to say to CRM Development Team …. what could be the problem ?

In fact as so far we do not do any test for restoring, and I know must do this due to the security reason.

Question 2
We found that on Linux server all was properly backuped.
When we copy them with to SMB resource and get to Windows station then even 7zip is unpacking them correctly.

We found that the problem is with sending them to local FTP server.
We are sending this files by this BASH script:

echo FTP file: $1 UPLOAD START
ftp -n <<END_SCRIPT
quote user userslogin
quote pass userspassw
cd /Backup
put $1
exit 0

Could somebody say how to improve/fix our FTP bash script ?

Answer :

You should tell them the way you generated the dump, since it is somewhat unusual. One obvious problem may be that they tried a decompression program that does not understand GNU zip.

I recommend to use the custom format:

pg_dump -F c -U postgres -f outfile.dmp $x

That can be restored with pg_restore, and it is automatically compressed.

Leave a Reply

Your email address will not be published. Required fields are marked *