Re: Using pg_start_backup() and pg_stop_backup() - using 9.1.2.2

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Khangelani Gama <kgama(at)argility(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using pg_start_backup() and pg_stop_backup() - using 9.1.2.2
Date: 2014-06-14 18:15:57
Message-ID: 1402769757.20902.YahooMailNeo@web122302.mail.ne1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Khangelani Gama <kgama(at)argility(dot)com> wrote:

> I am doing the following between master and the backup server
> using archive_command,

I'm not sure what that means.  Do you mean that while performing
the steps you describe, an archive command was active, copying WAL
files to an archive directory?

> On backup or secondary server I did the following:
>
> 1.       Stopped postgres in backup server
> 2.       Removed all walfiles from /walfiles directory
> 3.       Removed all files from pg_xlog/
>
> Went to master/source server:
>
> 1.       Issue pg_start_backup('label')
> 2.       Performed rsync of cluster directory  (nohup rsync -avz
>          /pgsql2/data backupserver:/pgsql2/ > /tmp/rsynccopy.out
>          2> /tmp/rsynccopy.err & )
> 3.       Step 2 takes a long time because the database is huge.
>          But during the rsync process many files are getting
>          copied to the backup server landing in /pgsql2/walfiles/
>          directory which I cleaned up before starting backup in
>          the master server.
> 4.       Once step 3, rsync is done I will run Issue
>          pg_stop_backup().

So far OK, although I would have told rsync to exclude the
postmaster.pid file and the contents of the pg_xlog directory.

> Then connect to secondary server and remove recovery.done and
> create recovery.conf file, and remove pid file which got copied
> from master server.

If you don't remove the files underneath pg_xlog, too, you will
have problems.  There is no telling at what point during the rsync
these were copied, so they are likely to be incomplete.  You can
only trust WAL files from the archive directory or taken while the
server which generated them is stopped.

> Question I have is After doing step 4, what do I with the files
> that have been copying as I mentioned in step 3 above or that
> have been copying during the rsync command. Do I have to copy any
> walfiles manually after doing step 4 above in the master server?

Your recovery.conf file should have a restore_command that copied
from the archive directory (walfiles) into the path indicated by
%p.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2014-06-14 18:24:58 Re: Designing a DB for storing biological data
Previous Message Adrian Klaver 2014-06-14 17:52:37 Re: Designing a DB for storing biological data