Re: Determining size of a database before dumping

From: Madison Kelly <linux(at)alteeve(dot)com>
To: Alexander Staubo <alex(at)purefiction(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Determining size of a database before dumping
Date: 2006-10-02 21:16:10
Message-ID: 4521819A.6030101@alteeve.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-10-02 21:19:46 Re: Determining size of a database before dumping
Previous Message Jim C. Nasby 2006-10-02 21:14:40 Re: Performance and Generic Config after install