Re: Best backup strategy for production systems

From: Oliver <ofabelo(at)gmail(dot)com>
To: François Beausoleil <francois(at)teksol(dot)info>
Cc: Forums postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best backup strategy for production systems
Date: 2014-06-19 10:14:36
Message-ID: CALQkqm83uQKhR=FPnBDtCyWarAsDUyLu3dZacFNZhc-_605iCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
thank you very much for your reply.
Ok, I've read again the official documentation about backup, slowly now ;-)
Is it correct if I use same location for archiving wal files and base
backups, isn't it? It will be in a different filesystem of $PGDATA.
OmniPITR allows be configured without having hot_standby? I have PostgreSQL
configured using "archive", for archiving wal files into a different
filesystem/path.
About many wal generated, reading documentation, I've done a error I think
.. :

*The archive command is only invoked on completed WAL segments. Hence, if
your server generates only little WAL traffic (or has slack periods where
it does so), there could be a long delay between the completion of a
transaction and its safe recording in archive storage. To put a limit on
how old unarchived data can be, you can setarchive_timeout
<http://www.postgresql.org/docs/current/static/runtime-config-wal.html#GUC-ARCHIVE-TIMEOUT>
to
force the server to switch to a new WAL segment file at least that often.
Note that archived files that are archived early due to a forced switch are
still the same length as completely full files. It is therefore unwise to
set a very short archive_timeout — it will bloat your archive
storage. archive_timeout settings of a minute or so are usually reasonable.*

So I modified my archive_timeout parameter to 60 .. so I understand now
that it is creating wal files each min. of 16MB each one, correct? Even not
being fill (because there isn't activity in the database), it will create
wal files each min. of 16MB, and for that, I've had my archiving filesystem
full quickly. Correct? I've modified parameter now to original value, 0, so
it is disabled now.
About wal files and archiving of them, I must delete both manually, isn't
it? There isn't any option for automatically delete wal files with a given
age in the postgresql.conf, isn't it? (Away of archive_command). Do you use
Linux? Could you pass me your archive_command or script that you use for
copying/gzipping the files?
Thanks beforehand.

Cheers...

2014-06-17 14:52 GMT+01:00 François Beausoleil <francois(at)teksol(dot)info>:

> Hi!
>
> Le 2014-06-17 à 08:31, Oliver <ofabelo(at)gmail(dot)com> a écrit :
>
> > Hi,
> > I'm a newbie in postgresql. I've mounted my first postgresql instance,
> it is empty now, only with default postgres DB.
> > It is under Linux, with 2 filesystems, one for data and another for
> archiving (I've enabled archiving as it will be for production).
> > Could someone recommend me a strategy for backups, scripts and so on?
> > Can base backup be done with the system up (postgres up), isn't it?
> > Would it be ok if I do a base backup each week and archiving backup each
> day?
> > As I've not configured backups (and archiving deletion), I've had my
> first problem and it is that my archiving filesystem (FS) is full and
> archiver process is showing "failed" with the last wal file copy (normal as
> archiving FS is full).
> > Please, recommend me what I should make now .. I should create another
> network FS for base backups and archiving backups? When I have my first
> base backup, could I then delete archiving files, isn't it?
> > My archiving FS has 20GB, I don't understand as with a system without
> load (it will be for production, but it hasn't databases now .. only
> postgres), how it full the FS in a few days ... Is it normal?
> > Thanks beforehand.
>
> Welcome to PostgreSQL!
>
> The PostgreSQL manual has a great section on backup and restore:
> http://www.postgresql.org/docs/current/static/backup.html
>
> I found value in « Instant PostgreSQL Backup and Restore How-To » at
> http://www.packtpub.com/how-to-postgresql-backup-and-restore/book
>
> Regarding your questions:
>
> * Yes, base backups can be made while the server is up and running.
> PostgreSQL has a tool named pg_basebackup to do just that
> http://www.postgresql.org/docs/current/static/app-pgbasebackup.html. I
> personally use OmniPITR to handle my base backups and continuous archiving
> https://github.com/omniti-labs/omnipitr . There also exists WAL-E
> https://github.com/wal-e/wal-e which backs up your data to S3 / Rackspace
> CloudFiles automatically.
>
> * Your WAL files are of no value once you have a new base backup: the new
> base backup includes all previous WAL files. You can think of a base backup
> as a snapshot. WAL files describe changes to the last snapshot. Depending
> on your rate of change, you can delete obsolete WAL files that are older
> than « a few days » than the last base backup. I personally keep 3 weeks of
> WAL files, 2 weeks of base backups.
>
> * The vacuum daemon will vacuum databases regularly, and checkpoints will
> also occur on a schedule, even on a system without activity. Those
> processes will generate some amount of WAL archives. WAL archives compress
> very well: 16MB to 4MB is very typical on my system.
>
> * My database is too big to do pg_dump (3 TiB), so I dont, but I have
> weekly base backups, plus the WAL archives which I keep for three weeks.
>
> Hope that helps!
> François Beausoleil
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message dinesh kumar 2014-06-19 10:37:09 Re: Insert query hangs what could be the reason
Previous Message M Tarkeshwar Rao 2014-06-19 08:29:04 Insert query hangs what could be the reason