[TriLUG] Using gzip to backup postgres to tape

Andrew Perrin clists at perrin.socsci.unc.edu
Wed Nov 29 09:20:27 EST 2006


OK gang, I figured it out... sometimes it just takes a really old book 
like _Essential System Administration_, 1st ed., to work on these things.


Here's the answer:

perrin:~# su postgres -c '/usr/bin/pg_dump -F t leted | /bin/gzip -c | 
/bin/dd of=/dev/nst0 obs=512 conv=sync'
615+1 records in
616+0 records out
315392 bytes (315 kB) copied, 9.98549 seconds, 31.6 kB/s


The dd command takes the gzipped input and pads it (that's what conv=sync 
means) to the output block size, in this case 512, which can be discovered 
using mt -f /dev/nst0 status.

Reading it back in is simple:

perrin:~# mt -f /dev/nst0 rewind
perrin:~# tar tzvf /dev/nst0
-rw------- 2048/1024     76972 2006-11-29 09:17 toc.dat
-rw------- 2048/1024    137045 2006-11-29 09:17 1661.dat
-rw------- 2048/1024        47 2006-11-29 09:17 1664.dat
-rw------- 2048/1024     25792 2006-11-29 09:17 1665.dat
-rw------- 2048/1024      8181 2006-11-29 09:17 1657.dat
-rw------- 2048/1024         5 2006-11-29 09:17 1666.dat
-rw------- 2048/1024         5 2006-11-29 09:17 1667.dat
-rw------- 2048/1024        22 2006-11-29 09:17 1652.dat
-rw------- 2048/1024        34 2006-11-29 09:17 1651.dat
-rw------- 2048/1024    566785 2006-11-29 09:17 1654.dat
-rw------- 2048/1024    191548 2006-11-29 09:17 1655.dat
-rw------- 2048/1024      4984 2006-11-29 09:17 1659.dat
-rw------- 2048/1024     57308 2006-11-29 09:17 1658.dat
-rw------- 2048/1024       111 2006-11-29 09:17 1660.dat
-rw------- 2048/1024        20 2006-11-29 09:17 1653.dat
-rw------- 2048/1024     10423 2006-11-29 09:17 1663.dat
-rw------- 2048/1024     48545 2006-11-29 09:17 1662.dat
-rw------- 2048/1024    342321 2006-11-29 09:17 1656.dat
-rw------- 2048/1024     80637 2006-11-29 09:17 restore.sql


Thanks to everyone for your suggestions.

Andy

----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin (at) unc.edu - http://perrin.socsci.unc.edu
Assistant Professor of Sociology; Book Review Editor, _Social Forces_
University of North Carolina - CB#3210, Chapel Hill, NC 27599-3210 USA
New Book: http://www.press.uchicago.edu/cgi-bin/hfs.cgi/00/178592.ctl






More information about the TriLUG mailing list