Re: [GENERAL] pg_dumpall from a script

2013-10-23 Thread Raghu Ram
On Tue, Oct 22, 2013 at 10:50 AM, James Sewell 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 :vari

Re: [GENERAL] pg_dumpall from a script

2013-10-23 Thread Oscar Calderon
Hi James, i wanna share with you a script that i use, i scheduled it with crontab. It generates a backup for each database. After that, there is another script scheduled that copies the backups to another server. #! /bin/bash TIEMPO=$(date '+%d%m%Y_%H%M%S') UBICACION="/var/lib/pgsql/9.3/backups_a

Re: [GENERAL] pg_dumpall from a script

2013-10-23 Thread Michael Nolan
You could write a plperlul function that runs a shell script to back up your database, you can even pass it parameters and put a call to that in a trigger. BUT, this could result in multiple backups running at the same time and become a performance drag. -- Mike Nolan On Tue, Oct 22, 2013 at 9:1

Re: [GENERAL] pg_dumpall from a script

2013-10-22 Thread James Sewell
Oh I missed that, I skimmed and thought it was the same as \set Turns out it's not and it's exactly what I want! Thanks! James Sewell, PostgreSQL Team Lead / Solutions Architect __ Level 2, 50 Queen St, Melbourne VIC 3000 *P *(+61) 3 8370 8000 * **W* www.

Re: [GENERAL] pg_dumpall from a script

2013-10-22 Thread Adrian Klaver
On 10/22/2013 03:41 PM, James Sewell wrote: Hello All, Thanks for the replies.Sorry I must have been a bit unclear, I realise I *could* do this from the shell level, but can I do it from a PSQL session somehow? Lucas' \setenv method won't work for you? Cheers, James Sewell, PostgreSQL Tea

Re: [GENERAL] pg_dumpall from a script

2013-10-22 Thread James Sewell
Hello All, Thanks for the replies.Sorry I must have been a bit unclear, I realise I *could* do this from the shell level, but can I do it from a PSQL session somehow? I think the answer is no (I assume unless I write my own C function or similar). It seems there is no way of passing a :variable

Re: [GENERAL] pg_dumpall from a script

2013-10-22 Thread Steve Crawford
On 10/21/2013 10:20 PM, James Sewell 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 wou

Re: [GENERAL] pg_dumpall from a script

2013-10-22 Thread Adrian Klaver
On 10/21/2013 11:41 PM, Luca Ferrari wrote: On Tue, Oct 22, 2013 at 7:20 AM, James Sewell wrote: 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. Could it be something like this: # \setenv myFile 'filename'

Re: [GENERAL] pg_dumpall from a script

2013-10-21 Thread Luca Ferrari
On Tue, Oct 22, 2013 at 7:20 AM, James Sewell wrote: > 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. Could it be something like this: # \setenv myFile 'filename' # \! pg_dump > $myFile Unfortunately there

Re: [GENERAL] pg_dumpall from a script

2013-10-21 Thread BladeOfLight16
On Tue, Oct 22, 2013 at 1:20 AM, James Sewell 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 :varia

Re: [GENERAL] pg_dumpall from a script

2013-10-21 Thread James Sewell
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 databa

Re: [GENERAL] pg_dumpall from a script

2013-10-21 Thread Raghu Ram
On Tue, Oct 22, 2013 at 8:07 AM, James Sewell wrote: > Hello, > > I need to trigger a database dump from a SQL script (or function, but I > think that is even less likely). > > I know I can do: > > \! pg_dumpall > /mydir/myfile > > Which is fine, but I need to use a variable to set the name. > > \

[GENERAL] pg_dumpall from a script

2013-10-21 Thread James Sewell
Hello, I need to trigger a database dump from a SQL script (or function, but I think that is even less likely). I know I can do: \! pg_dumpall > /mydir/myfile Which is fine, but I need to use a variable to set the name. \set myfile 'filename' \! pg_dumpall > /mydir/:myfile Doesn't seem to wor