Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
a5e90661
Commit
a5e90661
authored
Feb 22, 2008
by
tsmith@ramayana.hindu.god
Browse files
Options
Browse Files
Download
Plain Diff
Merge ramayana.hindu.god:/home/tsmith/m/bk/b28460/50
into ramayana.hindu.god:/home/tsmith/m/bk/build/50
parents
c93bb1bf
845b9445
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
75 deletions
+24
-75
scripts/mysqlhotcopy.sh
scripts/mysqlhotcopy.sh
+24
-75
No files found.
scripts/mysqlhotcopy.sh
View file @
a5e90661
...
@@ -39,7 +39,7 @@ WARNING: THIS PROGRAM IS STILL IN BETA. Comments/patches welcome.
...
@@ -39,7 +39,7 @@ WARNING: THIS PROGRAM IS STILL IN BETA. Comments/patches welcome.
# Documentation continued at end of file
# Documentation continued at end of file
my
$VERSION
=
"1.2
2
"
;
my
$VERSION
=
"1.2
3
"
;
my
$opt_tmpdir
=
$ENV
{
TMPDIR
}
||
"/tmp"
;
my
$opt_tmpdir
=
$ENV
{
TMPDIR
}
||
"/tmp"
;
...
@@ -132,7 +132,6 @@ GetOptions( \%opt,
...
@@ -132,7 +132,6 @@ GetOptions( \%opt,
# 'target' - destination directory of the copy
# 'target' - destination directory of the copy
# 'tables' - array-ref to list of tables in the db
# 'tables' - array-ref to list of tables in the db
# 'files' - array-ref to list of files to be copied
# 'files' - array-ref to list of files to be copied
# (RAID files look like 'nn/name.MYD')
# 'index' - array-ref to list of indexes to be copied
# 'index' - array-ref to list of indexes to be copied
#
#
...
@@ -263,7 +262,6 @@ my $hc_locks = "";
...
@@ -263,7 +262,6 @@ my $hc_locks = "";
my
$hc_tables
=
""
;
my
$hc_tables
=
""
;
my
$num_tables
=
0
;
my
$num_tables
=
0
;
my
$num_files
=
0
;
my
$num_files
=
0
;
my
$raid_dir_regex
=
'[A-Za-z0-9]{2}'
;
foreach my
$rdb
(
@db_desc
)
{
foreach my
$rdb
(
@db_desc
)
{
my
$db
=
$rdb
->
{
src
}
;
my
$db
=
$rdb
->
{
src
}
;
...
@@ -292,20 +290,12 @@ foreach my $rdb ( @db_desc ) {
...
@@ -292,20 +290,12 @@ foreach my $rdb ( @db_desc ) {
or die
"Cannot open dir '
$db_dir
':
$!
"
;
or die
"Cannot open dir '
$db_dir
':
$!
"
;
my %db_files
;
my %db_files
;
my @raid_dir
=
()
;
while
(
defined
(
my
$name
=
readdir DBDIR
)
)
{
while
(
defined
(
my
$name
=
readdir DBDIR
)
)
{
if
(
$name
=
~ /^
$raid_dir_regex$/
&&
-d
"
$db_dir
/
$name
"
)
{
$db_files
{
$name
}
=
$1
if
(
$name
=
~ /
(
.+
)
\.\w
+
$/
)
;
push @raid_dir,
$name
;
}
else
{
$db_files
{
$name
}
=
$1
if
(
$name
=
~ /
(
.+
)
\.\w
+
$/
)
;
}
}
}
closedir
(
DBDIR
)
;
closedir
(
DBDIR
)
;
scan_raid_dir
(
\%
db_files,
$db_dir
, @raid_dir
)
;
unless
(
keys %db_files
)
{
unless
(
keys %db_files
)
{
warn
"'
$db
' is an empty database
\n
"
;
warn
"'
$db
' is an empty database
\n
"
;
}
}
...
@@ -336,8 +326,6 @@ foreach my $rdb ( @db_desc ) {
...
@@ -336,8 +326,6 @@ foreach my $rdb ( @db_desc ) {
my @hc_tables
=
map
{
quote_names
(
"
$db
.
$_
"
)
}
@dbh_tables
;
my @hc_tables
=
map
{
quote_names
(
"
$db
.
$_
"
)
}
@dbh_tables
;
$rdb
->
{
tables
}
=
[
@hc_tables
]
;
$rdb
->
{
tables
}
=
[
@hc_tables
]
;
$rdb
->
{
raid_dirs
}
=
[
get_raid_dirs
(
$rdb
->
{
files
}
)
]
;
$hc_locks
.
=
", "
if
(
length
$hc_locks
&&
@hc_tables
)
;
$hc_locks
.
=
", "
if
(
length
$hc_locks
&&
@hc_tables
)
;
$hc_locks
.
=
join
", "
, map
{
"
$_
READ"
}
@hc_tables
;
$hc_locks
.
=
join
", "
, map
{
"
$_
READ"
}
@hc_tables
;
$hc_tables
.
=
", "
if
(
length
$hc_tables
&&
@hc_tables
)
;
$hc_tables
.
=
", "
if
(
length
$hc_tables
&&
@hc_tables
)
;
...
@@ -411,27 +399,24 @@ if ($opt{method} =~ /^cp\b/)
...
@@ -411,27 +399,24 @@ if ($opt{method} =~ /^cp\b/)
retire_directory
(
@existing
)
if
@existing
&&
!
$opt
{
addtodest
}
;
retire_directory
(
@existing
)
if
@existing
&&
!
$opt
{
addtodest
}
;
foreach my
$rdb
(
@db_desc
)
{
foreach my
$rdb
(
@db_desc
)
{
foreach my
$td
(
''
, @
{
$rdb
->
{
raid_dirs
}}
)
{
my
$tgt_dirpath
=
"
$rdb
->{target}"
;
# Remove trailing slashes (needed for Mac OS X)
my
$tgt_dirpath
=
"
$rdb
->{target}/
$td
"
;
substr
(
$tgt_dirpath
, 1
)
=
~ s|/+
$|
|
;
# Remove trailing slashes (needed for Mac OS X)
if
(
$opt
{
dryrun
}
)
{
substr
(
$tgt_dirpath
, 1
)
=
~ s|/+
$|
|
;
print
"mkdir
$tgt_dirpath
, 0750
\n
"
;
if
(
$opt
{
dryrun
}
)
{
}
print
"mkdir
$tgt_dirpath
, 0750
\n
"
;
elsif
(
$opt
{
method
}
=
~ /^scp
\b
/
)
{
}
## assume it's there?
elsif
(
$opt
{
method
}
=
~ /^scp
\b
/
)
{
## ...
## assume it's there?
}
## ...
else
{
}
mkdir
(
$tgt_dirpath
, 0750
)
or die
"Can't create '
$tgt_dirpath
':
$!
\n
"
else
{
unless
-d
$tgt_dirpath
;
mkdir
(
$tgt_dirpath
, 0750
)
or die
"Can't create '
$tgt_dirpath
':
$!
\n
"
if
(
$^
O
!
~ m/^
(
NetWare
)
$/
)
unless
-d
$tgt_dirpath
;
{
if
(
$^
O
!
~ m/^
(
NetWare
)
$/
)
my @f_info
=
stat
"
$datadir
/
$rdb
->{src}"
;
{
chown
$f_info
[
4],
$f_info
[
5],
$tgt_dirpath
;
my @f_info
=
stat
"
$datadir
/
$rdb
->{src}"
;
}
chown
$f_info
[
4],
$f_info
[
5],
$tgt_dirpath
;
}
}
}
}
}
}
...
@@ -489,7 +474,7 @@ foreach my $rdb ( @db_desc )
...
@@ -489,7 +474,7 @@ foreach my $rdb ( @db_desc )
my @files
=
map
{
"
$datadir
/
$rdb
->{src}/
$_
"
}
@
{
$rdb
->
{
files
}}
;
my @files
=
map
{
"
$datadir
/
$rdb
->{src}/
$_
"
}
@
{
$rdb
->
{
files
}}
;
next unless @files
;
next unless @files
;
eval
{
copy_files
(
$opt
{
method
}
,
\@
files,
$rdb
->
{
target
}
,
$rdb
->
{
raid_dirs
}
)
;
}
;
eval
{
copy_files
(
$opt
{
method
}
,
\@
files,
$rdb
->
{
target
})
;
}
;
push @failed,
"
$rdb
->{src} ->
$rdb
->{target} failed:
$@
"
push @failed,
"
$rdb
->{src} ->
$rdb
->{target} failed:
$@
"
if
(
$@
)
;
if
(
$@
)
;
...
@@ -582,7 +567,7 @@ exit 0;
...
@@ -582,7 +567,7 @@ exit 0;
# ---
# ---
sub copy_files
{
sub copy_files
{
my
(
$method
,
$files
,
$target
,
$raid_dirs
)
=
@_
;
my
(
$method
,
$files
,
$target
)
=
@_
;
my @cmd
;
my @cmd
;
print
"Copying "
.@
$files
.
" files...
\n
"
unless
$opt
{
quiet
}
;
print
"Copying "
.@
$files
.
" files...
\n
"
unless
$opt
{
quiet
}
;
...
@@ -603,15 +588,8 @@ sub copy_files {
...
@@ -603,15 +588,8 @@ sub copy_files {
# add recursive option for scp
# add recursive option for scp
$cp
.
=
" -r"
if
$^
O
=
~ /m^
(
solaris|linux|freebsd|darwin
)
$/
&&
$method
=
~ /^scp
\b
/
;
$cp
.
=
" -r"
if
$^
O
=
~ /m^
(
solaris|linux|freebsd|darwin
)
$/
&&
$method
=
~ /^scp
\b
/
;
my @non_raid
=
map
{
"'
$_
'"
}
grep
{
!
m:/
$raid_dir_regex
/[^/]+
$:
}
@
$files
;
# perform the actual copy
safe_system
(
$cp
,
(
map
{
"'
$_
'"
}
@
$files
)
,
"'
$target
'"
)
;
# add files to copy and the destination directory
safe_system
(
$cp
, @non_raid,
"'
$target
'"
)
if
(
@non_raid
)
;
foreach my
$rd
(
@
$raid_dirs
)
{
my @raid
=
map
{
"'
$_
'"
}
grep
{
m:
$rd
/:
}
@
$files
;
safe_system
(
$cp
, @raid,
"'
$target
'/
$rd
"
)
if
(
@raid
)
;
}
}
}
else
else
{
{
...
@@ -789,35 +767,6 @@ sub get_row_hash {
...
@@ -789,35 +767,6 @@ sub get_row_hash {
return
$sth
->fetchrow_hashref
()
;
return
$sth
->fetchrow_hashref
()
;
}
}
sub scan_raid_dir
{
my
(
$r_db_files
,
$data_dir
, @raid_dir
)
=
@_
;
local
(
*
RAID_DIR
)
;
foreach my
$rd
(
@raid_dir
)
{
opendir
(
RAID_DIR,
"
$data_dir
/
$rd
"
)
or die
"Cannot open dir '
$data_dir
/
$rd
':
$!
"
;
while
(
defined
(
my
$name
=
readdir RAID_DIR
)
)
{
$r_db_files
->
{
"
$rd
/
$name
"
}
=
$1
if
(
$name
=
~ /
(
.+
)
\.\w
+
$/
)
;
}
closedir
(
RAID_DIR
)
;
}
}
sub get_raid_dirs
{
my
(
$r_files
)
=
@_
;
my %dirs
=
()
;
foreach my
$f
(
@
$r_files
)
{
if
(
$f
=
~ m:^
(
$raid_dir_regex
)
/:
)
{
$dirs
{
$1
}
=
1
;
}
}
return
sort
keys %dirs
;
}
sub get_list_of_tables
{
sub get_list_of_tables
{
my
(
$db
)
=
@_
;
my
(
$db
)
=
@_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment