This script and associated output shows what you see when using
the validate option to check that a
single-file backup was not corrupted as it was transferred from
place to place.
validate Script
#! /bin/ksh # Demonstrate and test the 'validate' subcommand of mysqlbackup, # which works in combination with single-file backup. bdir=$(pwd)/backup full=$(pwd)/backup/single image=backup.image block=1234 # Arbitrary block to be corrupted db564=~/sandboxes/msb_5_6_4 config=$db564/my.sandbox.cnf mkdir -p $bdir rm -rf $full mkdir -p $full # --backup-dir needed here for temporary work files while producing the single-file backup image. # --backup-image could be a basic file name or the full path, it'll go under the same directory either way. mysqlbackup --defaults-file=$config --backup-dir=$full --backup-image=$full/$image backup-to-image echo; echo "*** Image File for Single-File Backup ***"; echo ls -l $full echo; echo "*** We expect this validation operation to succeed ***"; echo # For validating, we need the fully-qualified filename, --backup-dir doesn't help. mysqlbackup --backup-image=$full/$image validate echo; echo "*** Producing corrupted copy of single-image file ***"; echo dd of=$full/$image bs=8192 conv=notrunc count=1 oseek=$block if=/dev/random echo; echo "*** We expect this validation operation to fail ***"; echo mysqlbackup --backup-image=$full/$image validate
$ validate
MySQL Enterprise Backup version 3.7.0 [2011/12/07]
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All Rights Reserved.
INFO: Starting with following command line ...
mysqlbackup
--defaults-file=/Users/cirrus/sandboxes/msb_5_6_4/my.sandbox.cnf
--backup-dir=/Users/cirrus/downloads/meb37/test/backup/single
--backup-image=/Users/cirrus/downloads/meb37/test/backup/single/backup.image
backup-to-image
INFO: Got some server configuration information from running server.
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'backup-to-image' run mysqlbackup
prints "mysqlbackup completed OK!".
--------------------------------------------------------------------
Server Repository Options:
--------------------------------------------------------------------
datadir = /Users/cirrus/sandboxes/msb_5_6_4/data/
innodb_data_home_dir =
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /Users/cirrus/sandboxes/msb_5_6_4/data/
innodb_log_files_in_group = 2
innodb_log_file_size = 5242880
--------------------------------------------------------------------
Backup Config Options:
--------------------------------------------------------------------
datadir = /Users/cirrus/downloads/meb37/test/backup/single/datadir
innodb_data_home_dir = /Users/cirrus/downloads/meb37/test/backup/single/datadir
innodb_data_file_path = ibdata1:10M:autoextend
innodb_log_group_home_dir = /Users/cirrus/downloads/meb37/test/backup/single/datadir
innodb_log_files_in_group = 2
innodb_log_file_size = 5242880
Backup Image Path= /Users/cirrus/downloads/meb37/test/backup/single/backup.image
mysqlbackup: INFO: Unique generated backup id for this is 13234786599252660
mysqlbackup: INFO: System tablespace file format is Antelope.
mysqlbackup: INFO: Found checkpoint at lsn 183521501.
mysqlbackup: INFO: Starting log scan from lsn 183521280.
111209 16:57:39 mysqlbackup: INFO: Copying log...
111209 16:57:40 mysqlbackup: INFO: Log copied, lsn 183521501.
We wait 1 second before starting copying the data files...
111209 16:57:41 mysqlbackup: INFO: Copying /Users/cirrus/sandboxes/msb_5_6_4/data/ibdata1 (Antelope file format).
111209 16:57:47 mysqlbackup: INFO: Copying /Users/cirrus/sandboxes/msb_5_6_4/data/test/innodb_busy.ibd (Antelope file format).
111209 16:57:47 mysqlbackup: INFO: Copying /Users/cirrus/sandboxes/msb_5_6_4/data/test/innodb_quiet.ibd (Antelope file format).
mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
111209 16:57:47 mysqlbackup: INFO: Starting to lock all the tables....
111209 16:57:47 mysqlbackup: INFO: All tables are locked and flushed to disk
mysqlbackup: INFO: Opening backup source directory '/Users/cirrus/sandboxes/msb_5_6_4/data/'
111209 16:57:47 mysqlbackup: INFO: Starting to backup all files in subdirectories of '/Users/cirrus/sandboxes/msb_5_6_4/data/'
mysqlbackup: INFO: Backing up the database directory 'mysql'
mysqlbackup: INFO: Backing up the database directory 'performance_schema'
mysqlbackup: INFO: Backing up the database directory 'test'
mysqlbackup: INFO: Copying innodb data and logs during final stage ...
mysqlbackup: INFO: A copied database page was modified at 183521501.
(This is the highest lsn found on page)
Scanned log up to lsn 183524641.
Was able to parse the log up to lsn 183524641.
Maximum page number for a log record 467
111209 16:57:47 mysqlbackup: INFO: All tables unlocked
mysqlbackup: INFO: All MySQL tables were locked for 0.000 seconds
111209 16:57:48 mysqlbackup: INFO: Full backup completed!
mysqlbackup: WARNING: backup-image already closed
mysqlbackup: INFO: Backup image created successfully.:
Image Path: '/Users/cirrus/downloads/meb37/test/backup/single/backup.image'
-------------------------------------------------------------
Parameters Summary
-------------------------------------------------------------
Start LSN : 183521280
End LSN : 183524641
-------------------------------------------------------------
mysqlbackup completed OK!
*** Image File for Single-File Backup ***
total 237272
-rw-r--r-- 1 cirrus staff 188 Dec 9 16:57 backup-my.cnf
-rw-r--r-- 1 cirrus staff 121478567 Dec 9 16:57 backup.image
drwx------ 3 cirrus staff 102 Dec 9 16:57 datadir
drwx------ 6 cirrus staff 204 Dec 9 16:57 meta
*** We expect this validation operation to succeed ***
MySQL Enterprise Backup version 3.7.0 [2011/12/07]
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All Rights Reserved.
INFO: Starting with following command line ...
mysqlbackup
--backup-image=/Users/cirrus/downloads/meb37/test/backup/single/backup.image
validate
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'validate' run mysqlbackup
prints "mysqlbackup completed OK!".
mysqlbackup: INFO: Validating image ... /Users/cirrus/downloads/meb37/test/backup/single/backup.image
mysqlbackup: INFO: Backup Image MEB version string: 3.7.0 [2011/12/07]
mysqlbackup: INFO: Total files as specified in image: 188
mysqlbackup: INFO: Backup Image validation successful.
mysqlbackup completed OK!
*** Producing corrupted copy of single-image file ***
1+0 records in
1+0 records out
8192 bytes transferred in 0.000953 secs (8596382 bytes/sec)
*** We expect this validation operation to fail ***
MySQL Enterprise Backup version 3.7.0 [2011/12/07]
Copyright (c) 2003, 2011, Oracle and/or its affiliates. All Rights Reserved.
INFO: Starting with following command line ...
mysqlbackup
--backup-image=/Users/cirrus/downloads/meb37/test/backup/single/backup.image
validate
IMPORTANT: Please check that mysqlbackup run completes successfully.
At the end of a successful 'validate' run mysqlbackup
prints "mysqlbackup completed OK!".
mysqlbackup: INFO: Validating image ... /Users/cirrus/downloads/meb37/test/backup/single/backup.image
mysqlbackup: INFO: Backup Image MEB version string: 3.7.0 [2011/12/07]
mysqlbackup: ERROR: Component file checksum mismatch found!.
File path: datadir/ibdata1.$_append_$.2
mysqlbackup: ERROR: Backup image validation failed.

User Comments
Add your own comment.