~akopytov/percona-xtrabackup/bug713267-1.6

« back to all changes in this revision

Viewing changes to test/t/bug1002688.sh

  • Committer: Alexey Kopytov
  • Date: 2012-05-22 14:52:54 UTC
  • Revision ID: akopytov@gmail.com-20120522145254-v0h6obuzrg8zc6ke
Bug #1002688: innobackupex incremental apply-log copies to wrong
directory

The problem was that the copy_dir_recursively() routine relied on both
the source path and the target one to be in the canonical format,
i.e. not having any trailing slashes. However, when copying files after
merging an incremental backup to the full backup directory, the target
path (i.e. the full backup directory) was always in the canonical
format, because innobackupex calls File::Spec->rel2abs() on it in
check_args(), but the source path (i.e. the --incremental-directory
value) might not be in the canonical format in case the user specified
it with a trailing slash.

Fixed by canonizing both source and the target directories in
copy_dir_recursively() so it does not rely on the arguments format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
############################################################################
 
2
# Bug #1002688: innobackupex incremental apply-log copies to wrong directory
 
3
############################################################################
 
4
. inc/common.sh
 
5
 
 
6
init
 
7
run_mysqld --innodb_file_per_table
 
8
load_sakila
 
9
 
 
10
# Full backup
 
11
# backup root directory
 
12
vlog "Starting backup"
 
13
 
 
14
full_backup_dir=$topdir/full_backup
 
15
innobackupex  --no-timestamp $full_backup_dir
 
16
 
 
17
# Changing data
 
18
 
 
19
run_cmd $MYSQL $MYSQL_ARGS -e "CREATE DATABASE newdb"
 
20
run_cmd $MYSQL $MYSQL_ARGS -e \
 
21
    "CREATE TABLE actor_copy ENGINE=MyISAM SELECT * FROM sakila.actor" newdb
 
22
 
 
23
# Saving the checksum of original table
 
24
checksum_a=`checksum_table newdb actor_copy`
 
25
test -n "$checksum_a" || die "Failed to checksum table actor_copy"
 
26
 
 
27
vlog "Making incremental backup"
 
28
 
 
29
# Incremental backup
 
30
inc_backup_dir=$topdir/incremental_backup
 
31
innobackupex --incremental --no-timestamp \
 
32
    --incremental-basedir=$full_backup_dir $inc_backup_dir
 
33
vlog "Incremental backup created in directory $inc_backup_dir"
 
34
 
 
35
vlog "Preparing backup"
 
36
innobackupex --apply-log --redo-only $full_backup_dir
 
37
vlog "Log applied to full backup"
 
38
 
 
39
innobackupex --apply-log --redo-only --incremental-dir=$inc_backup_dir/ \
 
40
    $full_backup_dir
 
41
vlog "Delta applied to full backup"
 
42
 
 
43
innobackupex --apply-log $full_backup_dir
 
44
vlog "Data prepared for restore"
 
45
 
 
46
# Destroying mysql data
 
47
stop_mysqld
 
48
rm -rf $mysql_datadir/*
 
49
vlog "Data destroyed"
 
50
 
 
51
# Restore backup
 
52
vlog "Copying files to their original locations"
 
53
innobackupex --copy-back $full_backup_dir
 
54
vlog "Data restored"
 
55
 
 
56
run_mysqld --innodb_file_per_table
 
57
 
 
58
vlog "Checking checksums"
 
59
checksum_b=`checksum_table newdb actor_copy`
 
60
 
 
61
vlog "Old checksum: $checksum_a"
 
62
vlog "New checksum: $checksum_b"
 
63
 
 
64
if [ "$checksum_a" != "$checksum_b"  ]
 
65
then 
 
66
    vlog "Checksums do not match"
 
67
    exit -1
 
68
fi