Re: pg_dumpall from a script

From: Raghu Ram <raghuchennuru(at)gmail(dot)com>
To: James Sewell <james(dot)sewell(at)lisasoft(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_dumpall from a script
Date: 2013-10-24 05:38:24
Message-ID: CALnrrJRSaN5=NcPmW_SD5JoVH=9K2D5iwE+GqcdNdQ389fgLow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 22, 2013 at 10:50 AM, James Sewell <james(dot)sewell(at)lisasoft(dot)com>wrote:

> That looks great, but it doesn't really help with my problem unless I'm
> missing something (very possible!)
>
> I need a way to backup either from SQL in PSQL (possibly \!) or from a
> PG/PLSQL function to a file with a name set from a :variable.
>
> This would be triggered by a certain action in the database (applying a
> patch).
>
> Hope that's a bit clearer!
>
>
>
You can use a stored procedure with this plsh
http://plsh.projects.postgresql.org/ , like this:

CREATE FUNCTION dump_db(text, text) RETURNS text AS '

#!/bin/sh

pg_dump $1 > $2

' LANGUAGE plsh;

Note that you must CREATE LANGUAGE first, $1 is db_name, $2 is file name
and check for write permissions of $2.

Thanks & Regards

Raghu Ram

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eelke Klein 2013-10-24 06:42:15 Wrong estimate in query plan
Previous Message John R Pierce 2013-10-24 04:33:32 Re: PostgreSQL Point In Time Recovery