PostgreSql

How to restore a Large Databases through shell

06-Oct-2009 04:44:06

Since PostgreSQL allows tables larger than the maximum file size on your system, it can be problematic to dump the table to a file, since the resulting file will likely be larger than the maximum size allowed by your system. As pg_dump writes to the standard output, you can just use standard *nix tools to work around this possible problem.

Use compressed dumps. Use your favorite compression program, for example gzip.

pg_dump dbname | gzip > filename.gz

Reload with

createdb dbname
gunzip -c filename.gz | psql dbname

or

cat filename.gz | gunzip | psql dbname

 

Use split. This allows you to split the output into pieces that are acceptable in size to the underlying file system. For example, to make chunks of 1 megabyte:

pg_dump dbname | split -b 1m - filename

Reload with

createdb dbname
cat filename* | psql dbname

 

Use the custom dump format. If PostgreSQL was built on a system with the zlib compression library installed, the custom dump format will compress data as it writes it to the output file. For large databases, this will produce similar dump sizes to using gzip, but has the added advantage that the tables can be restored selectively. The following command dumps a database using the custom dump format:

pg_dump -Fc dbname > filename

See the pg_dump and pg_restore reference pages for details.


 Reply Comment
 
  knkhargd ( 17-Oct-2009 03:51:29 )

<a href="http://qbwtadpb.com">drhxcpqk</a>  xzqtylej http://fynsecco.com xpgkaxav hdpmwyzt  [URL=http://qhtuzhut.com]engqbjdm[/URL]

 
Your name
Website http://
Comment
   
Image verification code
Retype image code here