From: | Alexander Staubo <alex(at)purefiction(dot)net> |
---|---|
To: | Madison Kelly <linux(at)alteeve(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Determining size of a database before dumping |
Date: | 2006-10-02 20:46:37 |
Message-ID: | D2D9BE54-4590-4281-A947-9102ADD17B1C@purefiction.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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.
From | Date | Subject | |
---|---|---|---|
Next Message | Madison Kelly | 2006-10-02 20:52:15 | Re: Determining size of a database before dumping |
Previous Message | Steve Wampler | 2006-10-02 20:43:39 | Re: Determining size of a database before dumping |