PostgreSQL Backup Strategies



Similar documents
Backup and Recovery using PITR Mark Jones EnterpriseDB Corporation. All rights reserved. 1

Module 7. Backup and Recovery

Be Very Afraid. Christophe Pettus PostgreSQL Experts Logical Decoding & Backup Conference Europe 2014

How To Run A Standby On Postgres (Postgres) On A Slave Server On A Standby Server On Your Computer (Mysql) On Your Server (Myscientific) (Mysberry) (

MapGuide Open Source Repository Management Back up, restore, and recover your resource repository.

Configuring Apache Derby for Performance and Durability Olav Sandstå

Herve Roggero 3/3/2015

Administering your PostgreSQL Geodatabase

Database Hardware Selection Guidelines

High Availability Solutions for the MariaDB and MySQL Database

PostgreSQL 9.4 up and running.. Vasilis Ventirozos Database Administrator OmniTI

Outline. Failure Types

giovedì 4 ottobre 12

The Future of PostgreSQL High Availability Robert Hodges - Continuent, Inc. Simon Riggs - 2ndQuadrant

Oracle Database 10g: Backup and Recovery 1-2

MySQL Enterprise Backup

A Quick Start Guide to Backup Technologies

Scala InfoChannel Content Manager 5 Backup and Restore Instructions

Module 14: Scalability and High Availability

Appendix A Core Concepts in SQL Server High Availability and Replication

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

Percona Server features for OpenStack and Trove Ops

Ingres Backup and Recovery. Bruno Bompar Senior Manager Customer Support

Backup and Restore Instructions. Backing up the Content Manager s Data

Enhancing SQL Server Performance

PostgreSQL 9.0 Streaming Replication under the hood Heikki Linnakangas

Oracle Backup & Recovery

Using Time Machine to Backup Multiple Mac Clients to SNC NAS and 1000

Redundancy Options. Presented By: Chris Williams

SQL Server Replication Guide

Virtual Infrastructure Security

DB2 9 for LUW Advanced Database Recovery CL492; 4 days, Instructor-led

CitusDB Architecture for Real-Time Big Data

MySQL: Cloud vs Bare Metal, Performance and Reliability

WHITE PAPER. Dedupe-Centric Storage. Hugo Patterson, Chief Architect, Data Domain. Storage. Deduplication. September 2007

MySQL Backups: From strategy to Implementation

Business Process Desktop: Acronis backup & Recovery 11.5 Deployment Guide

EMC Backup and Recovery for Microsoft SQL Server 2008 Enabled by EMC Celerra Unified Storage

DISASTER RECOVERY WITH AWS

Postgres Plus Cloud Database!

Parallel Replication for MySQL in 5 Minutes or Less

PostgreSQL when it s not your job. Christophe Pettus PostgreSQL Experts, Inc. DjangoCon US 2012

Monitoring PostgreSQL database with Verax NMS

PostgreSQL when it s not your job. Christophe Pettus PostgreSQL Experts, Inc. DjangoCon Europe 2012

SnapManager for Oracle 2.2. Anand Ranganathan Product & Partner Engineer (PPE)

Database Virtualization

A Practical Guide to Backup and Recovery of IBM DB2 for Linux, UNIX and Windows in SAP Environments Part 1 Backup and Recovery Overview

Hadoop and Map-Reduce. Swati Gore

Pre-scheduled Control of Online Device-Based Backup and Incremental Data Backup in VMware Virtual System Environment

Parallels Cloud Server 6.0

Microsoft SQL Server 2008 Administrator's Pocket Consultant

White Paper. Alfresco Backup and Disaster Recovery

Nimble Storage Best Practices for Microsoft SQL Server

SQL Server Database Administrator s Guide

Why Not Oracle Standard Edition? A Dbvisit White Paper By Anton Els

4PSA Total Backup User's Guide. for Plesk and newer versions

Mind Q Systems Private Limited

This guide specifies the required and supported system elements for the application.

SQL Server 2012 Database Administration With AlwaysOn & Clustering Techniques

OLTP Meets Bigdata, Challenges, Options, and Future Saibabu Devabhaktuni

How to move an IDENTIKEY Authentication Server with embedded PostgreSQL DB to a new machine with new IP address?

A Deduplication File System & Course Review

Trends in Application Recovery. Andreas Schwegmann, HP

MySQL Replication. openark.org

ROADMAP TO DEFINE A BACKUP STRATEGY FOR SAP APPLICATIONS Helps you to analyze and define a robust backup strategy

VMware vsphere Data Protection 5.8 TECHNICAL OVERVIEW REVISED AUGUST 2014

EMC VNXe File Deduplication and Compression

VMware vsphere Data Protection 6.0

3. PGCluster. There are two formal PGCluster Web sites.

Chapter 14: Recovery System

VMware vsphere Data Protection 6.1

Oracle Recovery Manager

How To Use Rackspace Backup On A Computer Or A Hard Drive

Designing, Optimizing and Maintaining a Database Administrative Solution for Microsoft SQL Server 2008

Designing Database Solutions for Microsoft SQL Server 2012 MOC 20465

MS SQL Server 2014 New Features and Database Administration

High Availability and Disaster Recovery for Exchange Servers Through a Mailbox Replication Approach

11. Oracle Recovery Manager Overview and Configuration.

Flash for Databases. September 22, 2015 Peter Zaitsev Percona

RMAN What is Rman Why use Rman Understanding The Rman Architecture Taking Backup in Non archive Backup Mode Taking Backup in archive Mode

Understanding Disk Storage in Tivoli Storage Manager

Trends in Data Protection and Restoration Technologies. Mike Fishman, EMC 2 Corporation (Author and Presenter)

Microsoft SQL Server for Oracle DBAs Course 40045; 4 Days, Instructor-led

Availability Guide for Deploying SQL Server on VMware vsphere. August 2009

Backup and Recovery 1

InterBase SMP: Safeguarding Your Data from Disaster

MySQL Backup and Security. Best practices on how to run MySQL on Linux in a secure way Lenz Grimmer <lenz@mysql.com>

Protecting Microsoft SQL Server with Asigra Cloud Backup

How To Fix A Powerline From Disaster To Powerline

Solution Brief Availability and Recovery Options: Microsoft Exchange Solutions on VMware

Tushar Joshi Turtle Networks Ltd

Designing and Deploying Messaging Solutions with Microsoft Exchange Server 2010 Service Pack B; 5 days, Instructor-led

The Methodology Behind the Dell SQL Server Advisor Tool

Top 10 Reasons why MySQL Experts Switch to SchoonerSQL - Solving the common problems users face with MySQL

Transcription:

PostgreSQL Backup Strategies Austin PGDay 2012 Austin, TX Magnus Hagander magnus@hagander.net PRODUCTS CONSULTING APPLICATION MANAGEMENT IT OPERATIONS SUPPORT TRAINING

Replication! But I have replication! To multiple nodes! It's even in the cloud!

What about clustering? Yeah, pretty much the same

But my SAN is 100% up! Really?

But my SAN is 100% up! Really? No, really?!

Backup planning Backup interval Backup retention Performance impacts

Restore planning Time spent taking backups usually not important Time it takes to restore is critical Consider multi-stage solutions

PostgreSQL options Logical backups pg_dump Physical backups Filesystem snapshots pg_basebackup Manual base backups

Logical backups SQL script dump of schema + data Restored through SQL commands Great flexibility Not the greatest for performance

pg_dump This is your main tool Dumps a single database Regular PostgreSQL connection Guarantees consistent snapshot across database Single threaded (for now..)

pg_dump Supports multiple output formats Always use custom format (-Fc) Compressed by default Supports dumping separate objects For backups, always dump whole database

pg_dump system impact Runs regular COPY queries Uses single backend Does not ruin PostgreSQL cache ring buffer strategy used Can potentially ruin filesystem cache Writing of dump file causes I/O

pg_dump compression Compression happens in pg_dump Can be used for throttling Typical breakpoint at 3-5 Higher becomes CPU bound Lower becomes I/O bound

pg_dump ssh tunnel ssh dbserver "pg_dump -Z9 -Fc -U postgres mydb" > mydb.dump ssh -o "Compression=no" magh.u.bitbit.net "pg_dump -Z9 -Fc -U postgres mydb" > mydb.dump

Restoring from pg_dump Use pg_restore Reads custom format dumps Regular connection Full database restore Recover from backups Partial database restore Create staging env Single table restore

Restore performance Regular COPY Followed by CREATE INDEX And ADD CONSTRAINT Very slow for large databases!

Restore performance Use -1 flag Full restore as single transaction Enables multiple optimizations Particularly if WAL archiving not enabled Empty database in case of crash

Restore performance Restore in parallel sessions -j <n> Each object still in one session Not compatible with -1 Need to pick one -j usually faster

Restore performance Turn fsync=off Last resort But quite useful Don't forget to turn it back on! (Yes, it happens) Don't forget to flush OS caches! (Yes, you'll get corruption)

Physical backups

Physical backups PostgreSQL stores database in files We can backup those files... No need to parse or query Thus faster! Architecture, version, compile flags and paths must be identical Only full cluster backups

Offline backups Easiest possible way Stop PostgreSQL, take backup, start PostgreSQL Backup files any way possible Tar, copy, filesystem snapshot etc Not to be ignored...

Simple snapshot backups Filesystem/SAN snapshots while database is running Requires atomic snapshot across all tablespaces Including pg_xlog Mainly useful in small installations

Online base backups Non-constrained filesystem level backups Recoverable in combination with transaction log With or without log archive Provides base for PITR

Online base backups Integrated base backups On top of replication protocol Enable replication! wal_level=archive max_wal_senders=2

Online full backups pg_basebackup -U postgres -D backup -P -x Requires enough WAL to stay around Generates complete data directory

Log archiving As log is generated, send to archive On restoring, fetch back from archive Start from base backup Roll forward through archived log Stop at any point

Log archiving in PostgreSQL archive_mode=on Starts the log archiver archive_command=<something> take file x and store it under the name y restore_command=<something> give me back the file you stored under name y

Log archiving limitations Always 16Mb segments archive_timeout=<n> Too much or not enough Replication solves problem in 9.1 9.2: pg_receivexlog

Base backups for PITR pg_basebackup without -x Manual method: SELECT pg_start_backup(); <copy files> Copy files, e.g. cp/tar Rsync SAN snapshots SELECT pg_stop_backup();

pg_basebackup system impact Reads all data, generates lots of I/O pg_basebackup single threaded This is probably a good thing Sequential reads (Optional) compression happens in pg_basebackup, not server

Restore performance Depends on distance to base backup Read back all log files, replays Generates random writes Single threaded as well Multiple generations of base backups

Backup strategies

Please make backups

How to back up You definitely want online physical backups You almost certainly want PITR You probably want pg_dump If you can afford it

Backup retention Comes back to business requirements How far back does it make sense to restore data? And at what resolutions?

Log file/base backup Restore requires base backup + all log files since with no holes Keep fewer base backups but all logs Keep fewer logs but more base backups

Backup vs replication You probably want both Backups are more important Replication good for hardware failure And allows for much shorter service interruption

Lagged behind replicas Using file based replication Introduce delay in the system E.g. 1 hour or 12 hours Roll forward replica instead of restoring from backups

Testing your backups

Testing your backups We all know we should And we seldom do

Use for staging and dev Restore from backup instead of deploy from master Do not automate!

Thank you! Questions? Share your stories! Twitter: @magnushagander http://blog.hagander.net/ magnus@hagander.net

PostgreSQL Conference Europe 2012 October 23-26 See you in Prague!