Re: Is it safe to stop postgres in between pg_start_backup and pg_stop_backup?

Поиск
Список
Период
Сортировка
От Steven Schlansker
Тема Re: Is it safe to stop postgres in between pg_start_backup and pg_stop_backup?
Дата
Msg-id F53C63BF-325D-4FCE-BD0A-D4A8CC1B86AC@likeness.com
обсуждение исходный текст
Ответ на Is it safe to stop postgres in between pg_start_backup and pg_stop_backup?  (Jacob Scott <jacob.scott@gmail.com>)
Ответы Re: Is it safe to stop postgres in between pg_start_backup and pg_stop_backup?  (Alan Hodgson <ahodgson@simkin.ca>)
Список pgsql-general
On Apr 2, 2014, at 3:08 PM, Jacob Scott <jacob.scott@gmail.com> wrote:

> Hi,

Hello there ;)

>
>
> Does upgrading a a disk being used by postgres (9.1, on Ubuntu) with the following process sound safe?
>     • pg_start_backup
>     • Take a filesystem snapshot (of a volume containing postgres data but not pg_xlog)
>     • Bring a new higher performing disk online from snapshot
>     • pg_ctl stop
>     • switch disks (umount/remount at same mountpoint)
>     • pg_ctl start
>     • pg_stop_backup
> This seems like an odd use case because pg_start_backup is designed for performing on-line backups, but I think it
willgive me minimum downtime. 

At the very least you need to move your pg_stop_backup earlier in the process.  Online backups do not survive server
shutdowns;any backup in process at shutdown is aborted. 

    • pg_start_backup
    • Take a filesystem snapshot (of a volume containing postgres data but not pg_xlog)
    • pg_stop_backup
    • pg_ctl stop
    • Bring a new higher performing disk online from snapshot
    • switch disks (umount/remount at same mountpoint)
    • pg_ctl start

Assuming you ensure that your archived xlogs are available same to the new instance as the old, I believe this should
work. But run it on a test instance first! 

It sounds like an odd use case but really it’s no different from “the data is gone, restore from backup” — just that
youintentionally trashed the data by switching disks :) 

Another option you could consider is rsync.  I have often transferred databases by running rsync concurrently with the
databaseto get a “dirty backup” of it.  Then once the server is shutdown you run a cleanup rsync which is much faster
thanthe initial run to ensure that the destination disk is consistent and up to date.  This way your downtime is
limitedto how long it takes rsync to compare fs trees / fix the inconsistencies. 

Good luck!



В списке pgsql-general по дате отправления:

Предыдущее
От: Jacob Scott
Дата:
Сообщение: Is it safe to stop postgres in between pg_start_backup and pg_stop_backup?
Следующее
От: Matthew Chambers
Дата:
Сообщение: Re: Spring JDBC and the PostgreSQL JDBC driver