Re: ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no? - Mailing list pgsql-general

From Steven Schlansker
Subject Re: ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no?
Date
Msg-id 8B1637E3-3FC8-450A-9E7C-5035417C2C48@likeness.com
Whole thread Raw
In response to ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no?  (Gregory Haase <haaseg@onefreevoice.com>)
Responses Re: ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no?  (Gregory Haase <haaseg@onefreevoice.com>)
List pgsql-general
On Sep 11, 2013, at 4:29 PM, Gregory Haase <haaseg@onefreevoice.com> wrote:

> I was trying to figure out how to get the following syntax to work:
>
> echo "select pg_start_backup('zfs_snapshot'); \\! zfs snapshot zroot/zpgsql@test; \\ select pg_stop_backup();" | psql
postgres

I do:

psql -c "select pg_start_backup('whatever');" && zfs snapshot pool/fs@sn && psql -c "select pg_stop_backup();"

That way no need to shell out from psql :)

>
> The above command successfully starts the backup and creates the snapshot but then fails to stop the backup. I've
triedvarious combinations of \ and \\ here with different whitespace and I just can't seem to find a combination that
works.I don't understand the proper use of \\ (described as the separator metacommand). 

Keep in mind that echo "\\"  will actually only echo '\' because \ is a shell escape as well...

>
> However, in my research, I noted that a bunch of people seem to just not even bother with
pg_start_backup/pg_stop_backupand I guess aren't that worried about the crash recovery process if they need to perform
arestore. I also find the omission of the start/stop backup functions from the File System Level Backup page:
http://www.postgresql.org/docs/9.2/static/backup-file.html
>
> Is the pg_start_backup() and pg_stop_backup() even necessary?
>

If all of your Postgres files are part of *the same* consistent snapshot (i.e. are on one FS that gets snapshotted),
thenthe start/stop backup should not be necessary.  It will just look like a server crash instead. 

pg_start_backup is used when you do not have filesystem snapshotting available, and is described in detail on the next
manualpage: 

http://www.postgresql.org/docs/9.2/static/continuous-archiving.html



pgsql-general by date:

Previous
From: Gregory Haase
Date:
Subject: ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no?
Next
From: Gregory Haase
Date:
Subject: Re: ZFS snapshots - to use pg_start_backup() and pg_stop_backup() or no?