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



Similar documents
Module 7. Backup and Recovery

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) (

PostgreSQL Backup Strategies

PostgreSQL 9.0 Streaming Replication under the hood Heikki Linnakangas

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

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

Implementing the Future of PostgreSQL Clustering with Tungsten

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

Administering your PostgreSQL Geodatabase

EDB Backup and Recovery Tool Guide

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

Ingres Backup and Recovery. Bruno Bompar Senior Manager Customer Support

Comparing MySQL and Postgres 9.0 Replication

AVALANCHE MC 5.3 AND DATABASE MANAGEMENT SYSTEMS

IMF Tune v7.0 Backup, Restore, Replication

Technical Notes. PostgreSQL backups with NetWorker. Release number REV 01. June 30, u Audience u Requirements...

Managing SAS Web Infrastructure Platform Data Server High-Availability Clusters

Performing Administrative Tasks

How to Dump and Restore Postgres Plus (R) Databases Using pgadmin. A Postgres Evaluation Quick Tutorial From EnterpriseDB

Yiwo Tech Development Co., Ltd. EaseUS Todo Backup. Reliable Backup & Recovery Solution. EaseUS Todo Backup Solution Guide. All Rights Reserved Page 1

Restore and Recovery Tasks. Copyright 2009, Oracle. All rights reserved.

White Paper. Alfresco Backup and Disaster Recovery

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

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

Hyper-V backup implementation guide

Introduction. Setup of Exchange in a VM. VMware Infrastructure

WHITE PAPER: ENTERPRISE SOLUTIONS. Symantec Backup Exec Continuous Protection Server Continuous Protection for Microsoft SQL Server Databases

MySQL Backups: From strategy to Implementation

Configure AlwaysOn Failover Cluster Instances (SQL Server) using InfoSphere Data Replication Change Data Capture (CDC) on Windows Server 2012

Oracle Database 10g: Backup and Recovery 1-2

Backup and Recovery. What Backup, Recovery, and Disaster Recovery Mean to Your SQL Anywhere Databases

11. Configuring the Database Archiving Mode.

Perforce Backup Strategy & Disaster Recovery at National Instruments

LifeKeeper for Linux PostgreSQL Recovery Kit. Technical Documentation

Oracle Backup & Recovery

EMC NetWorker Module for Microsoft Applications Release 2.3. Application Guide P/N REV A02

MySQL Backup IEDR

Version: Page 1 of 5

Symantec Backup Exec 2014 Icon List

Implementing an Enterprise Class Database Backup and Recovery Plan

Open-Xchange Server Backup Whitepaper

A Quick Start Guide to Backup Technologies

Disaster Recovery on the Sun Cobalt RaQ 3 Server Appliance with Third-Party Software

Oracle Recovery Manager

Pervasive PSQL Meets Critical Business Requirements

Contents. SnapComms Data Protection Recommendations

Zen Internet. Online Data Backup. Zen Vault Professional Plug-ins. Issue:

Veritas NetBackup for Microsoft Exchange Server Administrator s Guide

Virtual Infrastructure Security

High Availability with Postgres Plus Advanced Server. An EnterpriseDB White Paper

Agenda. Overview Configuring the database for basic Backup and Recovery Backing up your database Restore and Recovery Operations Managing your backups

Backup Exec 12.5 Icons Glossary

Support Document: Microsoft SQL Server - LiveVault 7.6X

McAfee Endpoint Encryption Hot Backup Implementation

How To Use A Microsoft Networker Module For Windows (Windows) And Windows 8 (Windows 8) (Windows 7) (For Windows) (Powerbook) (Msa) (Program) (Network

Click Studios. Passwordstate. High Availability Installation Instructions

EMC NetWorker Module for Microsoft for Windows Bare Metal Recovery Solution

Demystifying Perforce Backup and Near-Real-Time Replication

A SURVEY OF POPULAR CLUSTERING TECHNOLOGIES

BEST PRACTICES GUIDE: VMware on Nimble Storage

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

Neverfail for Windows Applications June 2010

Planning, Implementing and Managing SafeBoot Enterprise Systems

SQL-BackTrack the Smart DBA s Power Tool for Backup and Recovery

Database Recovery For Newbies

RMAN BACKUP & RECOVERY. Recovery Manager. Veeratteshwaran Sridhar

13.1 Backup virtual machines running on VMware ESXi / ESX Server

Database Backup and Restore Mechanism. Presented by : Mary Meladath

Nimble Storage Best Practices for Microsoft SQL Server

Rajan Arora (Deloitte) SAP Business Objects Backup and Recovery Scenarios and Best Practices Session # 3233

SQL Server for Database Administrators Course Syllabus

VERITAS NetBackup 6.0 for Microsoft Exchange Server

Microsoft SQL Database Administrator Certification

Scala InfoChannel Content Manager 5 Backup and Restore Instructions

Using Emergency Restore to recover the vcenter Server has the following benefits as compared to the above methods:

BackupAssist v6 quickstart guide

Handling Hyper-V. In this series of articles, learn how to manage Hyper-V, from ensuring high availability to upgrading to Windows Server 2012 R2

MySQL Enterprise Backup

SQL Server 2008 Designing, Optimizing, and Maintaining a Database Session 1

DB2 backup and recovery

BUSINESS CONTINUITY AND DISASTER RECOVERY FOR ORACLE 11g

BACKING-UP HYPER-V VIRTUAL MACHINES WITH VICEVERSA PRO

HYPERION RELEASE BACKUP AND RECOVERY GUIDE

EMC DOCUMENTUM xplore 1.1 DISASTER RECOVERY USING EMC NETWORKER

Backups and Maintenance

Administration Guide - Documentum idataagent (DB2)

SAP Note FAQ: SAP HANA Database Backup & Recovery

Netezza PureData System Administration Course

Protecting Exchange 2010

Maximum Availability Architecture. Oracle Best Practices For High Availability. Backup and Recovery Scenarios for Oracle WebLogic Server: 10.

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

Rapid recovery from bare metal, to dissimilar hardware or to and from virtual environments.

Westek Technology Snapshot and HA iscsi Replication Suite

Nimble Storage Best Practices for Microsoft Hyper-V R2

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

How To Fix A Powerline From Disaster To Powerline

Transcription:

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

Agenda Introduction Business Impact Vs Cost Downtime Scenarios Backup Methods SQL Dump Cold Backup (Offline Backups) Hot Backup (Online Backup) Online Backups Continuous Archiving Online Backups Recovery Solutions Point-In Time Recovery Concepts Recovery Example 2015 EnterpriseDB Corporation. All rights reserved. 2

Introduction Backup and Recovery Strategies are absolutely key to the successful operation of any business critical data management. Database backup strategies must plan for catastrophic failure of a device, maintenance, disaster at a location, operator error, data corruption, and compliance requirements. 2015 EnterpriseDB Corporation. All rights reserved. 3

Business Impact vs Cost How long will recovery take? How long do we need to store backup data? How much will data storage cost? Will an outage effect our Brand? Can any part of the database remain operational whilst I recover elsewhere? Do I know when the problem I am recovering from started? 2015 EnterpriseDB Corporation. All rights reserved. 4

Downtime Scenarios Device Failure Maintenance Site Failure Operator Error Data Corruption Compliance 2015 EnterpriseDB Corporation. All rights reserved. 5

Device Failure Loss of Machine Loss of Disk Loss Of Power Site Failure Datacenter Failure Network Failure Office Break-In 2015 EnterpriseDB Corporation. All rights reserved. 6

Data Corruption Application introduces poor code and in turn corrupts the data Disk level corruption Operator Error Update error Dropped table Dropped schema Deletion of datafile 2015 EnterpriseDB Corporation. All rights reserved. 7

Maintenance Hardware upgrades O/S upgrades Compliance Data Retention Periods Readable data Writeable data Storage of data 2015 EnterpriseDB Corporation. All rights reserved. 8

Backup Methods As with any database, Postgres database should be backed up regularly. There are three fundamentally different approaches to backing up Postgres data: SQL dump File system level backup Continuous Archiving 2015 EnterpriseDB Corporation. All rights reserved. 9

Backup - SQL Dump Generate a text file with SQL commands Postgre provides the utility program pg_dump for this purpose. pg_dump does not block readers or writers. Dumps created by pg_dump are internally consistent, that is, the dump represents a snapshot of the database as of the time pg_dump begins running. Syntax: pg_dump [options] [dbname] 2015 EnterpriseDB Corporation. All rights reserved. 10

Backup - Entire Cluster SQL Dump pg_dumpall is used to dump an entire database cluster in plain-text SQL format Dumps global objects - user, groups, and associated permissions Use PSQL to restore Syntax: pg_dumpall [options ] > filename.backup 2015 EnterpriseDB Corporation. All rights reserved. 11

SQL Dump - Large Databases If operating systems have maximum file size limits, it can cause problems when creating large pg_dump output files. Standard Unix tools can be used to work around this potential problem. You can use your favorite compression program, for example gzip: pg_dump dbname gzip > filename.gz Also the split command allows you to split the output into smaller files: pg_dump dbname split -b 1m - filename 2015 EnterpriseDB Corporation. All rights reserved. 12

Backup Cold Backup An alternative backup strategy is to directly copy the files that Postgres uses to store the data in the database. You can use whatever method you prefer for doing usual file system backups, for example: tar -cf backup.tar /usr/local/pgsql/data The database server must be shut down in order to get a usable backup. File system backups only work for complete backup and restoration of an entire database cluster. 2015 EnterpriseDB Corporation. All rights reserved. 13

Backup Hot Backup A Hot Backup allows the database to stay operational during backup Postgres maintains WAL files for all transactions in the pg_xlog directory Postgres automatically maintains the wal logs which are full and switched Continuous archiving can be setup to keep a copy of switched WAL Logs which can be later used for recovery It also enables online file system backup of a database cluster Requirements: wal_level must be set to archive archive_mode must be set to on archive_command must be set in postgresql.conf which archives WAL logs and supports PITR 2015 EnterpriseDB Corporation. All rights reserved. 14

Continuous Archiving Edit the postgresql.conf file and set the archive parameters: wal_level=archive archive_mode=on Unix: archive_command= cp %p /mnt/server/archivedir/%f %p is the absolute path of WAL otherwise you can define the path %f is a unique file name which will be created on above path 2015 EnterpriseDB Corporation. All rights reserved. 15

Online Base Backup Make a base backup Connect using psql and issue the command: SELECT pg_start_backup( any useful label ); Use a standard file system backup utility to back up the /data subdirectory Connect using psql and issue the command: SELECT pg_stop_backup(); Continuously archive the WAL segment files 2015 EnterpriseDB Corporation. All rights reserved. 16

Online Base Backup Using pg_basebackup tool pg_basebackup can take a base backup of a Postgres cluster. This backup can be used for PITR or Streaming Replication. pg_basebackup makes a binary copy of the database cluster files. The system is automatically put in and out of backup mode. 2015 EnterpriseDB Corporation. All rights reserved. 17

Options for pg_basebackup Command line options for pg_basebackup: -D <directory name> - Location of backup -F <p or t> - Backup files format. Plain(p) or tar(t) -X - include required transaction log files -z - enable gzip compression for files -Z - level - Compression level -P - Progress Reporting -h - host - host on which cluster is running -p - port - cluster port To create a base backup of the server at localhost and store it in the local directory /usr/local/pgsql/backup: $ pg_basebackup -h locahost -D /usr/backup 2015 EnterpriseDB Corporation. All rights reserved. 18

pg_basebackup - Online Backup Steps require to take Base Backup: Modify pg_hba.conf host replication enterprisedb [Ipv4 address of client]/32 trust Modify postgresql.conf archive_command = 'cp -i %p /Users/postgres/archive/%f archive_mode = on # Require Restart max_wal_senders = 3 # Maximum 'wal_senders wal_keep_segments = 50 # How many WAL segments (=files should be kept on the server wal_level=archive Backup Command: pg_basebackup -D /usr/backup/testbackup -v -h 127.0.0.1 -U postgres 2015 EnterpriseDB Corporation. All rights reserved. 19

Recovery Solutions PITR Pg_restore Replication Replication with Failover and Switchback Delayed Replication Snapshots 2015 EnterpriseDB Corporation. All rights reserved. 20

Backup and Recovery Paths PITR Replication Delayed Replication Failover/ switchback Pg_restore Restore from Cold Backup Snapshots Device Failure Site Failure Data Corruption Operator error Maintenance Compliance Best Fit Good Fit Choose Better Alternatives 2015 EnterpriseDB Corporation. All rights reserved. 21

Point-in-Time Recovery Concepts Point-in-time recovery (PITR) is the ability to restore a database cluster up to the present or to a specified point of time in the past. Uses a full database cluster backup and the write-ahead logs found in the /pg_xlog subdirectory. Must be configured before it is needed (write-ahead log archiving must be enabled). Must have information of when you want to recover to? 2015 EnterpriseDB Corporation. All rights reserved. 22

Performing Point-in-Time Recovery Stop the server, if it's running. If you have enough space keep a copy of the data directory and transaction logs. Remove all directories and files from the cluster data directory. Restore the database files from your file system backup. Verify the ownership of restored backup directories (must not be root). Remove any files present in pg_xlog/. If you have any unarchived WAL segment files recovered from crashed cluster, copy them into pg_xlog/. Create a recovery command file recovery.conf in the cluster data directory. Start the server. Upon completion of the recovery process, the server will rename recovery.conf to recovery.done. 2015 EnterpriseDB Corporation. All rights reserved. 23

Point-in-Time Recovery Options Settings in the recovery.conf file: restore_command(string) Unix: restore_command = 'cp /mnt/server/archivedir/%f "%p" recovery_target_name (string) (select pg_create_restore_point( Name'); recovery_target_time(timestamp) recovery_target_xid(string) recovery_target_inclusive(boolean) pause_at_recovery_target (boolean) recovery_target immediate 2015 EnterpriseDB Corporation. All rights reserved. 24

Point-in-Time Recovery help Hot_standby = on postgres.conf if using pause pause_at_recovery_target = true Select pg_is_xlog_replay_paused(); Select pg_xlog_replay_resume(); 2015 EnterpriseDB Corporation. All rights reserved. 25

Summary Introduction Business Impact Vs Cost Backup Methods SQL Dump Cold Backup (Offline Backups) Hot Backup (Online Backup) Online Backups Continuous Archiving Online Backups Point-In Time Recovery Concepts Recovery Example 2015 EnterpriseDB Corporation. All rights reserved. 26

2015 EnterpriseDB Corporation. All rights reserved. 27