Re: pg_dump in stand alone backend - Mailing list pgsql-general

From Daniel Martini
Subject Re: pg_dump in stand alone backend
Date
Msg-id 1093256320.4129c4801b826@webmail.uni-hohenheim.de
Whole thread Raw
In response to pg_dump in stand alone backend  (Ulrich Wisser <ulrich.wisser@relevanttraffic.se>)
Responses Re: pg_dump in stand alone backend  (Ulrich Wisser <ulrich.wisser@relevanttraffic.se>)
List pgsql-general
Hi,

Citing Ulrich Wisser <ulrich.wisser@relevanttraffic.se>:
> I would like to stop the postmaster every night and run
>
> vacuum
> pg_dump
> reindex
>
> in the stand alone backend.
>
> Vacuum and reindex seem to be quite easy, as I can setup a small script
> with both commands. But what about pg_dump. That seems "somewhat" more
> complex.

What exactly is your problem about putting pg_dump in a (shell)script as
well?
In the simplest case you could use something like:

#!/bin/sh
psql --command vacuum your_database
cd /somewhere/with/write/access
pg_dump your_database > dump_`date %Y%m%d%H%M%S`.bak
psql --command 'reindex whatever_you_want_to_reindex' your_database

which will vacuum, dump to a file named dump_timewhendumpoccured.bak and
reindex whatever_you_want_to_reindex. All kinds of stuff could be added
(like mailing command output to you, loading the backup up to another
machine for storage etc. etc.), but above script does basically what
you were asking for.

Regards,
Daniel

pgsql-general by date:

Previous
From: Graeme Hinchliffe
Date:
Subject: Catching server shutdown in C
Next
From: "SVGK, Raju (Raju)"
Date:
Subject: view triggers/procedures