percona xtrabackup backup to cloud storage (swift)
TRANSCRIPT
An open source, free MySQL® hot backupsoftware that performs non-blockingbackups for InnoDB and XtraDB databasesfor Percona Server, Oracle MySQL &MariaDBPercona XtraBackup
3
Percona XtraBackup - 2.2Online Backup
Multi Threaded
Compression
Encryption
Streaming Backups
Delta/Incremental Support
Partial Backup/Restore
5
Percona XtraBackup - 2.3innobackupex is no longer, all built in xtrabackup!
Support for immediate backup streaming to Swift
Currently Beta
Planned to be in OpenStack Trove Liberty in the future (Tesora)
Amazon S3 support will be added in the future.
6
Configuring Percona XtraBackup[xtrabackup]compresscompress-threads=4encrypt=AES256encrypt-key='VERY_VERY_VERY_VERY_INSECURE_KEY'encrypt-threads=4stream=xbstream
[xtrabackup_decompress_decrypt]decompressdecompress-threads=4decrypt=AES256
7
Configuring Percona XtraBackup[xtrabackup]compresscompress-threads=4encrypt=AES256encrypt-key='VERY_VERY_VERY_VERY_INSECURE_KEY'encrypt-threads=4stream=xbstream
[xtrabackup_decompress_decrypt]decompressdecompress-threads=4decrypt=AES256
[xbcloud]parallel=4storage=swiftswift-auth-url=http://swift:8080/swift-auth-version=1.0 # 1.0-TempAuth, 2.0-Keystone_v2.0, 3-Keystone_v3swift-user="test:tester"swift-key=testingswift-container=Backup
8
Taking Full BackupBackup:
export date=`date '+%Y-%M-%d_%H-%M-%S'`xtrabackup --backup | xbcloud put "Full/$date"
Show Backup:
swift list Backup
9
Recovering Full BackupGet Data:
mkdir /restorexbcloud get Full/2015-05-22_23-05-55 | xbstream -x -v -C /restore
Decompress & Decrypt:
xtrabackup --defaults-group-suffix=_decompress_decrypt --target-dir=/restore
Prepare the backup (in this example, with incremental support):
xtrabackup --prepare --apply-log-only --target-dir=/restore
Copy Back:
xtrabackup --copy-back --target-dir=/restorechown -R mysql:mysql /var/lib/mysql
10
Taking Incremental BackupMore Challenging to get LSN, with encrypted backups
export incrdate=`date '+%Y-%M-%d_%H-%M-%S'`xtrabackup --backup \ --incremental-lsn=`xtrabackup_swift_encrypted_incremental_lsn \ Backup Full/2015-05-22_23-05-55` | \ xbcloud put "Incremental/$incrdate"
11
Getting LSN For IncrementalEncrypted Backupsxtrabackup_swift_encrypted_incremental_lsn:
#!/bin/bash
container=$1backuppath=$2encryptionkey=/root/swift.keytmpdir=`mktemp -d`
( swift download -o - $container \ $backuppath/xtrabackup_checkpoints.xbcrypt.00000000000000000000; swift download -o - $container \ $backuppath/xtrabackup_checkpoints.xbcrypt.00000000000000000001) |xbstream -x -C $tmpdir
cat $tmpdir/xtrabackup_checkpoints.xbcrypt | \ xbcrypt -d -a AES256 -f $encryptionkey | \ grep to_lsn | awk '{print $3}'
rm -rf $tmpdir
12
Recover Incremental BackupLets get the incremental from Swift:
Decompress & Decrypt:
xtrabackup --defaults-group-suffix=_decompress_decrypt \ --target-dir=/restore_incremental
Apply the incremental on the already prepared full
xtrabackup --prepare --apply-log-only \ --target-dir=/restore/ --incremental-dir=/restore_incremental
Restore:
xtrabackup --copy-back --target-dir=/restore
mkdir /restore_incrementalxbcloud get Incremental/2015-36-22_23-36-54 | xbstream -x -v -C /restore_incremental
13
Percona XtraBackupBackup To Cloud Storage
Download beta today:
https://www.percona.com/blog/2015/05/20/percona-xtrabackup-
2-3-1-beta1-is-now-available/
Feedback appreciated!
Questions?
Don't forget to rate talks with the Percona Live Amsterdam App!
Kenny Gryp (@gryp)
14