SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler offline
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
1
MySQL Enterprise Backup:
PITR Partial Online Recovery
Keith Hollman
MySQL Principal Sales Consultant EMEA
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
3
Agenda
 Objectives for today.
 Backup and what to do.
 Restore procedures.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
4
Objectives
 Backup Policy:
– Full Backup of the environment.
– Complemental Incremental backups & online BinLogs.
 Restore:
– Logical Restore.
– Online, Zero impact.
– Partial, single database, group of tables.
Backup & Restore
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
5
Backup
 A working environment, with 4 databases, of which 2 will require
restoration.
 Full backup with MySQL Enterprise Backup:
mysqlbackup --user=root --socket=/tmp/mysql.sock 
--backup-dir=/home/mysql/unit4/backup/ --with-timestamp backup
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
6
Backup
 Create 4 different databases, where the structure & content is the
same.
create database u4_1; use u4_1; create table `unit4` (`ID` int(7) NOT NULL
AUTO_INCREMENT, `Name` char(20) NOT NULL DEFAULT '‘, PRIMARY KEY (`ID`) )
ENGINE=InnoDB;
create database u4_2; use u4_2; create table `unit4` (...) ;
create database u4_3; use u4_3; create table `unit4` (...) ;
create database u4_4; use u4_4; create table `unit4` (...) ;
 Insert some rows in each of the “unit4” tables,
within each database:
call Unit4Insert (1000);
Test preparation
delimiter //
DROP PROCEDURE IF EXISTS Unit4Insert//
CREATE PROCEDURE Unit4Insert (p1 INT)
BEGIN
SET @x = 0;
REPEAT
INSERT INTO unit4 SELECT NULL, '1thousand';
SET @x = @x + 1;
UNTIL @x > p1 END REPEAT;
END
//
delimiter ;
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
7
Backup
 Then execute an incremental backup to safeguard the newly created
databases & objects and inserted rows.
mysqlbackup --user=root --socket=/tmp/mysql.sock 
--incremental-backup-dir=/home/mysql/unit4/backup_inc --with-timestamp 
--incremental --incremental_base=history:last_backup backup
Incremental
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
8
Recovery
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
9
Recovery
 We can:
1. convert the existing backup-dir to a single file backup and then extract it, or
2. go via the collection of tablespaces, locking and discarding as we go.
 Restore method also depends on whether:
1. tables have had rows deleted or modified (here we can use transportable
tablespaces)
2. if the object has been deleted, then we need to recreate it, from a
mysqldump extracted from a restored environment.
 In another separate environment or using a specific my.cnf.
2 Options for Logical Recovery.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
10
Recovery
 Bring the full backup up to date with all InnoDB data:
mysqlbackup --backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43/ apply-log
 Update the Full backup with the Incremental backup:
mysqlbackup --backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43/ 
--incremental-backup-dir=/home/mysql/unit4/backup_inc/2013-07-25_17-20-18 
apply-incremental-backup
 And then get a single consolidated image file to work from:
mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi 
--backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43 backup-dir-to-image
Preparing backups
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
11
Recovery
 Now let’s insert some rows, to reflect changes in the binlogs:
use u4_2
call Unit4Insert (1000);
select count(*) from unit4;
 And generate something to have to recover from:
delete from unit4 where id < 10;
select count(*) from unit4;
The Test
+----------+
| count(*) |
+----------+
| 2002 |
+----------+
+----------+
| count(*) |
+----------+
| 1993 |
+----------+
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
12
Recovery
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
13
The Recovery Scenario
 Objective:
– Restore the whole table with the logs applied, before the error.
– Online, without having to stop or impede access to the other users.
 So when did the error happen then? Let’s view the General_log:
vi ol63uek01.log
/delete from unit4
....
130729 13:16:29 2 Query delete from unit4 where id < 10
..
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
14
The Recovery Scenario
 What’s the backup history:
use mysql
select backup_id, start_time, end_time, binlog_pos, binlog_file, backup_type, backup_format,
backup_destination, exit_state from backup_history;
 Position =1654141 binlog = mysql-bin.000008
Backup status
+-------------------+---------------------+---------------------+------------+------------------+-------------+---------------
+---------------------------------------------------+------------+
| backup_id | start_time | end_time | binlog_pos | binlog_file | backup_type | backup_format
| backup_destination | exit_state |
+-------------------+---------------------+---------------------+------------+------------------+-------------+---------------
+---------------------------------------------------+------------+
| 13747094837220932 | 2013-07-25 01:44:43 | 2013-07-25 01:45:26 | 829045 | mysql-bin.000008 | FULL | DIRECTORY
| /home/mysql/unit4/backup/2013-07-25_01-44-43 | SUCCESS |
| 13747656186636058 | 2013-07-25 17:20:18 | 2013-07-25 17:20:46 | 1654141 | mysql-bin.000008 | INCREMENTAL | DIRECTORY
| /home/mysql/unit4/backup_inc/2013-07-25_17-20-18 | SUCCESS |
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
15
The Recovery Scenario
 To list single-file image contents:
mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi list-image
 Now we know where the 2 databases are, u4_2 & u4_4, extract them:
mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi 
--src-entry=datadir/u4_2 --dst-entry=/home/mysql/unit4/reco/u4_2 extract
mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi 
--src-entry=datadir/u4_4 --dst-entry=/home/mysql/unit4/reco/u4_4 extract
List contents & Extract
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
16
The Recovery Scenario
 We also know which binlog to start reading from, and from what
position, in order to gather all changes after the Incremental backup
and just before the "delete" occurred.
 Also, as there is more than 1 binlog, we pass the list on a single line:
mysqlbinlog --start-position=1654141 --stop-datetime="2013-07-29 13:16:28"
/binlogs/mysql-bin.000008 /binlogs/mysql-bin.000009 --base64-output=decode-rows
--verbose --database=u4_2 > recover_1654141_20130729131628.sql
 with this file, recover_1654141_20130729131628.sql, we can see the sql
commands COMMENTED OUT, i.e. any execution of this file will not
restore anything.
Next steps
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
17
The Recovery Scenario
 Now discard the original tables, and replace with the recovered ones
from the Full+INC image result set:
 Generate the ‘lock’ and ‘discard’ sql syntax:
select 'use u4_2' db, concat_ws(' ','lock tables',table_name,'write;') 'lock',
concat_ws(' ','alter table',table_name,'discard tablespace;') 'discard' from
tables where table_schema = 'u4_2';
select 'use u4_4' db, concat_ws(' ','lock tables',table_name,'write;') 'lock',
concat_ws(' ','alter table',table_name,'discard tablespace;') 'discard' from
tables where table_schema = 'u4_4';
use u4_2; lock tables unit4 write; alter table unit4 discard tablespace;
use u4_4; lock tables unit4 write; alter table unit4 discard tablespace;
Transportable tablespaces.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
18
The Recovery Scenario
 Copy the recovered .ibd files from the single file backup image:
cd /opt/mysql/mysql/data/u4_2
cp ~/unit4/reco/u4_2/*.ibd .
 Import the tablespaces:
select concat_ws(' ','alter table',table_name,'import tablespace;') 'import' from
tables where table_schema = 'u4_2';
alter table unit4 import tablespace;
 Unlock the tables (execute only once for all tables):
unlock tables;
Transportable tablespaces continued.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
19
The Recovery Scenario
 Time to apply the data extracted from the binlogs, after the incremental
backup:
mysqlbinlog --start-position=1654141 --stop-datetime="2013-07-29 13:16:28" 
/binlogs/mysql-bin.000008 /binlogs/mysql-bin.000009 --verbose --database=u4_2 
| mysql –uroot
 Confirm that we have restored the table with all its rows:
mysql> select count(*) from u4_2.unit4;
Transportable tablespaces continued.
+----------+
| count(*) |
+----------+
| 2002 |
+----------+
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
20
Other details
 Just some further details of the procedure and impact of restoring, at a
space requirement level:
/opt/mysql/mysql/data 546996 Kb
/home/mysql/unit4 1461780 Kb
- 1 full backup (uncompressed) 538984 Kb
- 1 incremental backup 383412 Kb
- 1 Full+INC single file image 538450 Kb
- Recovered db's (u4_2+u4_4) 328 Kb
- recover sql w/ comments script 576 Kb
- meta & datadir dir's 8 Kb
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
21
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
22
Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
23

Mais conteúdo relacionado

Mais procurados

Replication in PostgreSQL tutorial given in Postgres Conference 2019
Replication in PostgreSQL tutorial given in Postgres Conference 2019Replication in PostgreSQL tutorial given in Postgres Conference 2019
Replication in PostgreSQL tutorial given in Postgres Conference 2019Abbas Butt
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveSveta Smirnova
 
Plny12 galera-cluster-best-practices
Plny12 galera-cluster-best-practicesPlny12 galera-cluster-best-practices
Plny12 galera-cluster-best-practicesDimas Prasetyo
 
Architecture of exadata database machine – Part II
Architecture of exadata database machine – Part IIArchitecture of exadata database machine – Part II
Architecture of exadata database machine – Part IIParesh Nayak,OCP®,Prince2®
 
Oracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionOracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionAlex Gorbachev
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLMydbops
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesKenny Gryp
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteKenny Gryp
 
MySQLのバックアップ運用について色々
MySQLのバックアップ運用について色々MySQLのバックアップ運用について色々
MySQLのバックアップ運用について色々yoku0825
 
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)NTT DATA Technology & Innovation
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7Zhaoyang Wang
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performancePostgreSQL-Consulting
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016Wagner Bianchi
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQLLuca Garulli
 
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorialFrederic Descamps
 
MySQL GTID 시작하기
MySQL GTID 시작하기MySQL GTID 시작하기
MySQL GTID 시작하기I Goo Lee
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldJignesh Shah
 
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11Federico Razzoli
 

Mais procurados (20)

Replication in PostgreSQL tutorial given in Postgres Conference 2019
Replication in PostgreSQL tutorial given in Postgres Conference 2019Replication in PostgreSQL tutorial given in Postgres Conference 2019
Replication in PostgreSQL tutorial given in Postgres Conference 2019
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
PostgreSQL replication
PostgreSQL replicationPostgreSQL replication
PostgreSQL replication
 
Plny12 galera-cluster-best-practices
Plny12 galera-cluster-best-practicesPlny12 galera-cluster-best-practices
Plny12 galera-cluster-best-practices
 
Architecture of exadata database machine – Part II
Architecture of exadata database machine – Part IIArchitecture of exadata database machine – Part II
Architecture of exadata database machine – Part II
 
Oracle ASM 11g - The Evolution
Oracle ASM 11g - The EvolutionOracle ASM 11g - The Evolution
Oracle ASM 11g - The Evolution
 
Achieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQLAchieving High Availability in PostgreSQL
Achieving High Availability in PostgreSQL
 
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best PracticesMySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
MySQL InnoDB Cluster - New Features in 8.0 Releases - Best Practices
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suite
 
MySQLのバックアップ運用について色々
MySQLのバックアップ運用について色々MySQLのバックアップ運用について色々
MySQLのバックアップ運用について色々
 
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
YugabyteDBを使ってみよう - part2 -(NewSQL/分散SQLデータベースよろず勉強会 #2 発表資料)
 
New awesome features in MySQL 5.7
New awesome features in MySQL 5.7New awesome features in MySQL 5.7
New awesome features in MySQL 5.7
 
Linux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performanceLinux tuning to improve PostgreSQL performance
Linux tuning to improve PostgreSQL performance
 
MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016MySQL Multi-Source Replication for PL2016
MySQL Multi-Source Replication for PL2016
 
OrientDB introduction - NoSQL
OrientDB introduction - NoSQLOrientDB introduction - NoSQL
OrientDB introduction - NoSQL
 
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorialMySQL InnoDB Cluster and Group Replication in a Nutshell:  hands-on tutorial
MySQL InnoDB Cluster and Group Replication in a Nutshell: hands-on tutorial
 
MySQL GTID 시작하기
MySQL GTID 시작하기MySQL GTID 시작하기
MySQL GTID 시작하기
 
Greenplum Architecture
Greenplum ArchitectureGreenplum Architecture
Greenplum Architecture
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11
Webinar - Key Reasons to Upgrade to MySQL 8.0 or MariaDB 10.11
 

Destaque

Meb Backup & Recovery Performance
Meb Backup & Recovery PerformanceMeb Backup & Recovery Performance
Meb Backup & Recovery PerformanceKeith Hollman
 
Anthony conner media
Anthony conner mediaAnthony conner media
Anthony conner mediashynedatruth1
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA -   UKOUGEmbracing Database Diversity: The New Oracle / MySQL DBA -   UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUGKeith Hollman
 
MySQL Replication: Demo Réplica en Español
MySQL Replication: Demo Réplica en EspañolMySQL Replication: Demo Réplica en Español
MySQL Replication: Demo Réplica en EspañolKeith Hollman
 
MySQL Enterprise Backup
MySQL Enterprise BackupMySQL Enterprise Backup
MySQL Enterprise BackupMark Swarbrick
 
MySQL Cluster: El ‘qué’ y el ‘cómo’.
MySQL Cluster: El ‘qué’ y el ‘cómo’.MySQL Cluster: El ‘qué’ y el ‘cómo’.
MySQL Cluster: El ‘qué’ y el ‘cómo’.Keith Hollman
 

Destaque (6)

Meb Backup & Recovery Performance
Meb Backup & Recovery PerformanceMeb Backup & Recovery Performance
Meb Backup & Recovery Performance
 
Anthony conner media
Anthony conner mediaAnthony conner media
Anthony conner media
 
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA -   UKOUGEmbracing Database Diversity: The New Oracle / MySQL DBA -   UKOUG
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
 
MySQL Replication: Demo Réplica en Español
MySQL Replication: Demo Réplica en EspañolMySQL Replication: Demo Réplica en Español
MySQL Replication: Demo Réplica en Español
 
MySQL Enterprise Backup
MySQL Enterprise BackupMySQL Enterprise Backup
MySQL Enterprise Backup
 
MySQL Cluster: El ‘qué’ y el ‘cómo’.
MySQL Cluster: El ‘qué’ y el ‘cómo’.MySQL Cluster: El ‘qué’ y el ‘cómo’.
MySQL Cluster: El ‘qué’ y el ‘cómo’.
 

Semelhante a MySQL Enterprise Backup: PITR Partial Online Recovery

Making Backups in Extreme Situations
Making Backups in Extreme SituationsMaking Backups in Extreme Situations
Making Backups in Extreme SituationsSveta Smirnova
 
Oracle Database Backup
Oracle Database BackupOracle Database Backup
Oracle Database BackupHandy_Backup
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...Frederic Descamps
 
FOSDEM MySQL & Friends Devroom, February 2018 MySQL Point-in-Time Recovery l...
FOSDEM MySQL & Friends Devroom, February 2018  MySQL Point-in-Time Recovery l...FOSDEM MySQL & Friends Devroom, February 2018  MySQL Point-in-Time Recovery l...
FOSDEM MySQL & Friends Devroom, February 2018 MySQL Point-in-Time Recovery l...Frederic Descamps
 
Backups And Recovery
Backups And RecoveryBackups And Recovery
Backups And Recoveryasifmalik110
 
MySQL Enterprise Backup & Oracle Secure Backup
MySQL Enterprise Backup &  Oracle Secure BackupMySQL Enterprise Backup &  Oracle Secure Backup
MySQL Enterprise Backup & Oracle Secure BackupSanjay Manwani
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)Mydbops
 
Training Slides: 203 - Backup & Recovery
Training Slides: 203 - Backup & RecoveryTraining Slides: 203 - Backup & Recovery
Training Slides: 203 - Backup & RecoveryContinuent
 
Rman workshop short
Rman workshop shortRman workshop short
Rman workshop shortNabi Abdul
 
ODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskRuggero Citton
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAsMark Leith
 

Semelhante a MySQL Enterprise Backup: PITR Partial Online Recovery (20)

Making Backups in Extreme Situations
Making Backups in Extreme SituationsMaking Backups in Extreme Situations
Making Backups in Extreme Situations
 
Oracle backup
Oracle backupOracle backup
Oracle backup
 
Oracle Database Backup
Oracle Database BackupOracle Database Backup
Oracle Database Backup
 
Xpp c user_rec
Xpp c user_recXpp c user_rec
Xpp c user_rec
 
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...FOSDEM 2022 MySQL Devroom:  MySQL 8.0 - Logical Backups, Snapshots and Point-...
FOSDEM 2022 MySQL Devroom: MySQL 8.0 - Logical Backups, Snapshots and Point-...
 
Les 02 config
Les 02 configLes 02 config
Les 02 config
 
Les 07 rman_rec
Les 07 rman_recLes 07 rman_rec
Les 07 rman_rec
 
Les 05 create_bu
Les 05 create_buLes 05 create_bu
Les 05 create_bu
 
FOSDEM MySQL & Friends Devroom, February 2018 MySQL Point-in-Time Recovery l...
FOSDEM MySQL & Friends Devroom, February 2018  MySQL Point-in-Time Recovery l...FOSDEM MySQL & Friends Devroom, February 2018  MySQL Point-in-Time Recovery l...
FOSDEM MySQL & Friends Devroom, February 2018 MySQL Point-in-Time Recovery l...
 
Backup&recovery
Backup&recoveryBackup&recovery
Backup&recovery
 
Backups And Recovery
Backups And RecoveryBackups And Recovery
Backups And Recovery
 
MySQL Enterprise Backup & Oracle Secure Backup
MySQL Enterprise Backup &  Oracle Secure BackupMySQL Enterprise Backup &  Oracle Secure Backup
MySQL Enterprise Backup & Oracle Secure Backup
 
Power point oracle db 12c
Power point oracle db 12cPower point oracle db 12c
Power point oracle db 12c
 
MySQL Backup & Recovery
MySQL Backup & RecoveryMySQL Backup & Recovery
MySQL Backup & Recovery
 
MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)MySQL Enterprise Backup (MEB)
MySQL Enterprise Backup (MEB)
 
Training Slides: 203 - Backup & Recovery
Training Slides: 203 - Backup & RecoveryTraining Slides: 203 - Backup & Recovery
Training Slides: 203 - Backup & Recovery
 
Rman workshop short
Rman workshop shortRman workshop short
Rman workshop short
 
ODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live DiskODA Backup Restore Utility & ODA Rescue Live Disk
ODA Backup Restore Utility & ODA Rescue Live Disk
 
MySQL for Oracle DBAs
MySQL for Oracle DBAsMySQL for Oracle DBAs
MySQL for Oracle DBAs
 
Les 06 rec
Les 06 recLes 06 rec
Les 06 rec
 

Mais de Keith Hollman

Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Keith Hollman
 
MySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & DemoMySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & DemoKeith Hollman
 
MySQL Technology Overview
MySQL Technology OverviewMySQL Technology Overview
MySQL Technology OverviewKeith Hollman
 
MySQL 8.0 Released Update
MySQL 8.0 Released UpdateMySQL 8.0 Released Update
MySQL 8.0 Released UpdateKeith Hollman
 
MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)Keith Hollman
 
MySQL 8.0 InnoDB Cluster demo
MySQL 8.0 InnoDB Cluster demoMySQL 8.0 InnoDB Cluster demo
MySQL 8.0 InnoDB Cluster demoKeith Hollman
 
MySQL NoSQL JSON JS Python "Document Store" demo
MySQL NoSQL JSON JS Python "Document Store" demoMySQL NoSQL JSON JS Python "Document Store" demo
MySQL NoSQL JSON JS Python "Document Store" demoKeith Hollman
 
MySQL Una Introduccion Tecnica
MySQL Una Introduccion TecnicaMySQL Una Introduccion Tecnica
MySQL Una Introduccion TecnicaKeith Hollman
 
A MySQL Odyssey - A Blackhole Crossover
A MySQL Odyssey - A Blackhole CrossoverA MySQL Odyssey - A Blackhole Crossover
A MySQL Odyssey - A Blackhole CrossoverKeith Hollman
 

Mais de Keith Hollman (9)

Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
Moodle Moot Spain: Moodle Available and Scalable with MySQL HA - InnoDB Clust...
 
MySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & DemoMySQL InnoDB Cluster HA Overview & Demo
MySQL InnoDB Cluster HA Overview & Demo
 
MySQL Technology Overview
MySQL Technology OverviewMySQL Technology Overview
MySQL Technology Overview
 
MySQL 8.0 Released Update
MySQL 8.0 Released UpdateMySQL 8.0 Released Update
MySQL 8.0 Released Update
 
MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)MySQL Enterprise Edition - Complete Guide (2019)
MySQL Enterprise Edition - Complete Guide (2019)
 
MySQL 8.0 InnoDB Cluster demo
MySQL 8.0 InnoDB Cluster demoMySQL 8.0 InnoDB Cluster demo
MySQL 8.0 InnoDB Cluster demo
 
MySQL NoSQL JSON JS Python "Document Store" demo
MySQL NoSQL JSON JS Python "Document Store" demoMySQL NoSQL JSON JS Python "Document Store" demo
MySQL NoSQL JSON JS Python "Document Store" demo
 
MySQL Una Introduccion Tecnica
MySQL Una Introduccion TecnicaMySQL Una Introduccion Tecnica
MySQL Una Introduccion Tecnica
 
A MySQL Odyssey - A Blackhole Crossover
A MySQL Odyssey - A Blackhole CrossoverA MySQL Odyssey - A Blackhole Crossover
A MySQL Odyssey - A Blackhole Crossover
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 

MySQL Enterprise Backup: PITR Partial Online Recovery

  • 1. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1
  • 2. MySQL Enterprise Backup: PITR Partial Online Recovery Keith Hollman MySQL Principal Sales Consultant EMEA
  • 3. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3 Agenda  Objectives for today.  Backup and what to do.  Restore procedures.
  • 4. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4 Objectives  Backup Policy: – Full Backup of the environment. – Complemental Incremental backups & online BinLogs.  Restore: – Logical Restore. – Online, Zero impact. – Partial, single database, group of tables. Backup & Restore
  • 5. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5 Backup  A working environment, with 4 databases, of which 2 will require restoration.  Full backup with MySQL Enterprise Backup: mysqlbackup --user=root --socket=/tmp/mysql.sock --backup-dir=/home/mysql/unit4/backup/ --with-timestamp backup
  • 6. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6 Backup  Create 4 different databases, where the structure & content is the same. create database u4_1; use u4_1; create table `unit4` (`ID` int(7) NOT NULL AUTO_INCREMENT, `Name` char(20) NOT NULL DEFAULT '‘, PRIMARY KEY (`ID`) ) ENGINE=InnoDB; create database u4_2; use u4_2; create table `unit4` (...) ; create database u4_3; use u4_3; create table `unit4` (...) ; create database u4_4; use u4_4; create table `unit4` (...) ;  Insert some rows in each of the “unit4” tables, within each database: call Unit4Insert (1000); Test preparation delimiter // DROP PROCEDURE IF EXISTS Unit4Insert// CREATE PROCEDURE Unit4Insert (p1 INT) BEGIN SET @x = 0; REPEAT INSERT INTO unit4 SELECT NULL, '1thousand'; SET @x = @x + 1; UNTIL @x > p1 END REPEAT; END // delimiter ;
  • 7. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7 Backup  Then execute an incremental backup to safeguard the newly created databases & objects and inserted rows. mysqlbackup --user=root --socket=/tmp/mysql.sock --incremental-backup-dir=/home/mysql/unit4/backup_inc --with-timestamp --incremental --incremental_base=history:last_backup backup Incremental
  • 8. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8 Recovery
  • 9. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9 Recovery  We can: 1. convert the existing backup-dir to a single file backup and then extract it, or 2. go via the collection of tablespaces, locking and discarding as we go.  Restore method also depends on whether: 1. tables have had rows deleted or modified (here we can use transportable tablespaces) 2. if the object has been deleted, then we need to recreate it, from a mysqldump extracted from a restored environment.  In another separate environment or using a specific my.cnf. 2 Options for Logical Recovery.
  • 10. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10 Recovery  Bring the full backup up to date with all InnoDB data: mysqlbackup --backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43/ apply-log  Update the Full backup with the Incremental backup: mysqlbackup --backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43/ --incremental-backup-dir=/home/mysql/unit4/backup_inc/2013-07-25_17-20-18 apply-incremental-backup  And then get a single consolidated image file to work from: mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi --backup-dir=/home/mysql/unit4/backup/2013-07-25_01-44-43 backup-dir-to-image Preparing backups
  • 11. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11 Recovery  Now let’s insert some rows, to reflect changes in the binlogs: use u4_2 call Unit4Insert (1000); select count(*) from unit4;  And generate something to have to recover from: delete from unit4 where id < 10; select count(*) from unit4; The Test +----------+ | count(*) | +----------+ | 2002 | +----------+ +----------+ | count(*) | +----------+ | 1993 | +----------+
  • 12. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12 Recovery
  • 13. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13 The Recovery Scenario  Objective: – Restore the whole table with the logs applied, before the error. – Online, without having to stop or impede access to the other users.  So when did the error happen then? Let’s view the General_log: vi ol63uek01.log /delete from unit4 .... 130729 13:16:29 2 Query delete from unit4 where id < 10 ..
  • 14. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14 The Recovery Scenario  What’s the backup history: use mysql select backup_id, start_time, end_time, binlog_pos, binlog_file, backup_type, backup_format, backup_destination, exit_state from backup_history;  Position =1654141 binlog = mysql-bin.000008 Backup status +-------------------+---------------------+---------------------+------------+------------------+-------------+--------------- +---------------------------------------------------+------------+ | backup_id | start_time | end_time | binlog_pos | binlog_file | backup_type | backup_format | backup_destination | exit_state | +-------------------+---------------------+---------------------+------------+------------------+-------------+--------------- +---------------------------------------------------+------------+ | 13747094837220932 | 2013-07-25 01:44:43 | 2013-07-25 01:45:26 | 829045 | mysql-bin.000008 | FULL | DIRECTORY | /home/mysql/unit4/backup/2013-07-25_01-44-43 | SUCCESS | | 13747656186636058 | 2013-07-25 17:20:18 | 2013-07-25 17:20:46 | 1654141 | mysql-bin.000008 | INCREMENTAL | DIRECTORY | /home/mysql/unit4/backup_inc/2013-07-25_17-20-18 | SUCCESS |
  • 15. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15 The Recovery Scenario  To list single-file image contents: mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi list-image  Now we know where the 2 databases are, u4_2 & u4_4, extract them: mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi --src-entry=datadir/u4_2 --dst-entry=/home/mysql/unit4/reco/u4_2 extract mysqlbackup --backup-image=/home/mysql/unit4/backup/full_backup.mbi --src-entry=datadir/u4_4 --dst-entry=/home/mysql/unit4/reco/u4_4 extract List contents & Extract
  • 16. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16 The Recovery Scenario  We also know which binlog to start reading from, and from what position, in order to gather all changes after the Incremental backup and just before the "delete" occurred.  Also, as there is more than 1 binlog, we pass the list on a single line: mysqlbinlog --start-position=1654141 --stop-datetime="2013-07-29 13:16:28" /binlogs/mysql-bin.000008 /binlogs/mysql-bin.000009 --base64-output=decode-rows --verbose --database=u4_2 > recover_1654141_20130729131628.sql  with this file, recover_1654141_20130729131628.sql, we can see the sql commands COMMENTED OUT, i.e. any execution of this file will not restore anything. Next steps
  • 17. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 17 The Recovery Scenario  Now discard the original tables, and replace with the recovered ones from the Full+INC image result set:  Generate the ‘lock’ and ‘discard’ sql syntax: select 'use u4_2' db, concat_ws(' ','lock tables',table_name,'write;') 'lock', concat_ws(' ','alter table',table_name,'discard tablespace;') 'discard' from tables where table_schema = 'u4_2'; select 'use u4_4' db, concat_ws(' ','lock tables',table_name,'write;') 'lock', concat_ws(' ','alter table',table_name,'discard tablespace;') 'discard' from tables where table_schema = 'u4_4'; use u4_2; lock tables unit4 write; alter table unit4 discard tablespace; use u4_4; lock tables unit4 write; alter table unit4 discard tablespace; Transportable tablespaces.
  • 18. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 18 The Recovery Scenario  Copy the recovered .ibd files from the single file backup image: cd /opt/mysql/mysql/data/u4_2 cp ~/unit4/reco/u4_2/*.ibd .  Import the tablespaces: select concat_ws(' ','alter table',table_name,'import tablespace;') 'import' from tables where table_schema = 'u4_2'; alter table unit4 import tablespace;  Unlock the tables (execute only once for all tables): unlock tables; Transportable tablespaces continued.
  • 19. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 19 The Recovery Scenario  Time to apply the data extracted from the binlogs, after the incremental backup: mysqlbinlog --start-position=1654141 --stop-datetime="2013-07-29 13:16:28" /binlogs/mysql-bin.000008 /binlogs/mysql-bin.000009 --verbose --database=u4_2 | mysql –uroot  Confirm that we have restored the table with all its rows: mysql> select count(*) from u4_2.unit4; Transportable tablespaces continued. +----------+ | count(*) | +----------+ | 2002 | +----------+
  • 20. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 20 Other details  Just some further details of the procedure and impact of restoring, at a space requirement level: /opt/mysql/mysql/data 546996 Kb /home/mysql/unit4 1461780 Kb - 1 full backup (uncompressed) 538984 Kb - 1 incremental backup 383412 Kb - 1 Full+INC single file image 538450 Kb - Recovered db's (u4_2+u4_4) 328 Kb - recover sql w/ comments script 576 Kb - meta & datadir dir's 8 Kb
  • 21. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 21
  • 22. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 22
  • 23. Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 23