Обсуждение: Postgres 8.0 Backups

Поиск
Список
Период
Сортировка

Postgres 8.0 Backups

От
Pallav Kalva
Дата:
Hi Everybody,

    I am working on a backup script for Postgres 8.0 online backups and
since i have to copy the whole pgdata directory , i am wondering after i
copy the pgdata directory can I run gzip or tar on the data directory ?
is it safe to do gzip or tar and I can safely restore the backups later ?

Thanks in advance,
Pallav


Re: Postgres 8.0 Backups

От
Scott Marlowe
Дата:
On Mon, 2005-01-24 at 10:47, Pallav Kalva wrote:
> Hi Everybody,
>
>     I am working on a backup script for Postgres 8.0 online backups and
> since i have to copy the whole pgdata directory , i am wondering after i
> copy the pgdata directory can I run gzip or tar on the data directory ?
> is it safe to do gzip or tar and I can safely restore the backups later ?

Yes, however, you may have some issues to deal with.

Generally speaking, file system level backups are not the best way to
backup postgresql, since they require either shutting down the server or
using a snapshot file system to get a coherent backup.  File system
backups taken by normal copy / tar during database operation may result
in backups that don't work when you need them to.

pg_dump is generally the better way to back things up, and with the
right switches will create a Z compressed tar file automagically for
you.

Re: Postgres 8.0 Backups

От
Tom Lane
Дата:
Scott Marlowe <smarlowe@g2switchworks.com> writes:
> On Mon, 2005-01-24 at 10:47, Pallav Kalva wrote:
>> I am working on a backup script for Postgres 8.0 online backups and
>> since i have to copy the whole pgdata directory , i am wondering after i
>> copy the pgdata directory can I run gzip or tar on the data directory ?

> Generally speaking, file system level backups are not the best way to
> backup postgresql, since they require either shutting down the server or
> using a snapshot file system to get a coherent backup.

In the context of online backup operations, that advice isn't relevant
anymore ...

Personally I would do "tar cfz pgdata.tar.gz $PGDATA" or equivalent,
rather than making an explicit copy of the directory tree first.

            regards, tom lane

Re: Postgres 8.0 Backups

От
Scott Marlowe
Дата:
On Mon, 2005-01-24 at 12:05, Tom Lane wrote:
> Scott Marlowe <smarlowe@g2switchworks.com> writes:
> > On Mon, 2005-01-24 at 10:47, Pallav Kalva wrote:
> >> I am working on a backup script for Postgres 8.0 online backups and
> >> since i have to copy the whole pgdata directory , i am wondering after i
> >> copy the pgdata directory can I run gzip or tar on the data directory ?
>
> > Generally speaking, file system level backups are not the best way to
> > backup postgresql, since they require either shutting down the server or
> > using a snapshot file system to get a coherent backup.
>
> In the context of online backup operations, that advice isn't relevant
> anymore ...

Really, is this an 8.0 thing then, that I can make file system backups
and expect them to be coherent, or did I misunderhear what you meant and
this has to do with some other issue I'm not getting?

Re: Postgres 8.0 Backups

От
Tom Lane
Дата:
Scott Marlowe <smarlowe@g2switchworks.com> writes:
> On Mon, 2005-01-24 at 12:05, Tom Lane wrote:
>> In the context of online backup operations, that advice isn't relevant
>> anymore ...

> Really, is this an 8.0 thing then, that I can make file system backups
> and expect them to be coherent, or did I misunderhear what you meant and
> this has to do with some other issue I'm not getting?

No, it means that when doing PITR stuff you don't actually care that
your base backup isn't consistent --- you expect WAL replay to fix it.
See http://www.postgresql.org/docs/8.0/static/backup-online.html

            regards, tom lane

Re: Postgres 8.0 Backups

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Scott Marlowe <smarlowe@g2switchworks.com> writes:
> > On Mon, 2005-01-24 at 12:05, Tom Lane wrote:
> >> In the context of online backup operations, that advice isn't relevant
> >> anymore ...
>
> > Really, is this an 8.0 thing then, that I can make file system backups
> > and expect them to be coherent, or did I misunderhear what you meant and
> > this has to do with some other issue I'm not getting?
>
> No, it means that when doing PITR stuff you don't actually care that
> your base backup isn't consistent --- you expect WAL replay to fix it.
> See http://www.postgresql.org/docs/8.0/static/backup-online.html

Right, the big issue is that you have to be archiving the WAL logs
before you do the filesystem backup, and the WAL files will restore the
recovery to a consistent state.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073