Invalid Argument piping tar output through gzip to tape

I ran into trouble trying to use pg_dump, the postgresql backup utility, to back up databases to tape. Specifically, I wanted to compress the data since it's often sparse and I didn't want to waste increasingly-precious tape space.

My first stab at the problem involved: pg_dump -F t dbname | /bin/gzip -c > /dev/nst0

This resulted in the dreaded Invalid argument response only when writing to tape, and therefore in an incomplete archive being written.

After significant digging around, I determined that I needed to use dd to block the output of gzip for the tape. The manual to gnu tar notes that tar does this automatically when it pipes through gzip as a result of the -z option to tar. Using dd is necessary after the gzip pipe if it's done separately, as is necessary under pg_dump.

The command that works for me is:
pg_dump -F t dbname | /bin/gzip -c | dd of=/dev/nst0 obs=512 conv=sync

Also see this message for more: http://www.trilug.org/pipermail/trilug/Week-of-Mon-20061127/045355.html


Andrew J. Perrin
Last modified: Wed Nov 29 12:28:36 EST 2006