I'm trying to dump a huge database and compress the dump in order to not have to wait hours till it's done.
I dump the database the following way:
pg_dump -Fc -U -v | gzip > db$(date %d-%m-%y_%H-%M).tar.gz
This leaves me with a compressed tar file. I know want to unzip it in order to have a .tar file only:
tar -xvf xxx.tar.gz
This leaves me with an error message saying This does not look like a tar archive file
My goal is to then import it via psql. I do not see what I am doing wrong – according to the Postgres documentation on dumps, I can use -Fc to dump in any wanted format? Thank you
CodePudding user response:
It is not a tar archive, even if you named it like that, so you cannot use tar
to unpack it.
To restore, you could use
zcat xxx.tar.gz | pg_restore -d target_database -U dbuser
By the way, it is pretty pointless to compress a custom format dump, since it is already compressed. You could choose better compression during pg_dump
with the -Z 9
option.