Re: Best backup strategy for production systems

From: François Beausoleil <francois(at)teksol(dot)info>
To: Oliver <ofabelo(at)gmail(dot)com>
Cc: Forums postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Best backup strategy for production systems
Date: 2014-06-17 13:52:13
Message-ID: CC9B3A41-7B75-461E-8175-2E450B1B007A@teksol.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 Alban Hertroys 2014-06-17 14:22:47 Re: pg_restore: custom archiver unexpected end of file , ERROR: missing data for column
Previous Message Khangelani Gama 2014-06-17 12:53:36 Re: pg_restore: custom archiver unexpected end of file , ERROR: missing data for column