Search Postgresql Archives

Re: Determining size of a database before dumping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alexander Staubo wrote:
On Oct 2, 2006, at 22:17 , Madison Kelly wrote:

I am (re)writing a backup program and I want to add a section for backing up pSQL DBs. In the planning steps (making sure a given destination has enough space) I try to calculate how much space will be needed by a 'pg_dump' run *before* actually dumping it.

Is there a relatively easy way to do that? Moreso, if it possible to do this from an unpriviledged account? If not, is there a way to add the permissions to a specific pg user to allow that user to perform this?

You could dump the database to /dev/null, piping it through wc to catch the size, but that would of course be wasteful.

You could count the disk space usage of the actual stored tuples, though this will necessarily be inexact:

  http://www.postgresql.org/docs/8.1/static/diskusage.html

Or you could count the size of the physical database files (/var/lib/postgresql or wherever). While these would be estimates, you could at least guarantee that the dump would not *exceed* the esimtate.

Keep in mind that pg_dump can compress the dump and (iirc) will do so by default when you use the custom format (-Fc or --format=c).

Alexander.

Heh, that looks like just the article I would have wanted if I had properly RTFM. :D

Many thanks!!

Madi


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux