ensembl-hive
2.8.1
CreateFile4CopyDBoverServer.pl
Go to the documentation of this file.
1
#!/usr/bin/env perl
2
# See the NOTICE file distributed with this work for additional information
3
# regarding copyright ownership.
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
# http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
17
##########################################
18
#
19
# Simple but handy script that generate the input file
20
# neded by the script CopyDBoverServer.pl
21
#
22
# Please post comments/questions to the Ensembl development list
23
# <http://lists.ensembl.org/mailman/listinfo/dev>
24
#
25
#########################################
26
use strict;
27
use warnings;
28
use DBI;
29
use Getopt::Long;
30
31
my $help= 0;
32
my $sourceHost=
"ens-staging"
;
33
my $sourcePort=
"3306"
;
34
my $sourceUser=
""
;
35
my $sourcePwd=
""
;
36
my $destinationHost=
"mart2"
;
37
my $destinationPort=
"3306"
;
38
my $limit=
''
;
39
my $target_location =
''
;
40
41
my $usage =
"\nUsage: $0 -sourceHost mart1 -sourceUser xxx -destinationHost mart2 -limit %42%\n
42
-help or -h [for help]
43
44
-sourceHost [default: ens-staging]
45
-sourcePort [default: 3306 ]
46
-sourceUser [default: ]
47
-destinationHost [default: mart2 ]
48
-destinationPort [default: 3306 ]
49
-limit [eg. %core_42% ]
50
-target_location [default: blank if you want standard data locations]\n
51
52
The limit option will limit the databases being copied according to your limit criteria.
53
With -limit %core_42% only ensembl core 42 databases will be copied\n\n
54
"
;
55
56
GetOptions(
'help|h'
=> \$help,
57
'sourceHost=s'
=> \$sourceHost,
58
'sourcePort=s'
=> \$sourcePort,
59
'sourceUser=s'
=> \$sourceUser,
60
'sourcePwd=s'
=> \$sourcePwd,
61
'destinationHost=s'
=> \$destinationHost,
62
'destinationPort=s'
=> \$destinationPort,
63
'target_location=s'
=> \$target_location,
64
'limit=s'
=> \$limit);
65
66
if
($help || scalar @ARGV == 0 ) {
67
#if ($help) {
68
print $usage;
69
exit 0;
70
}
71
#--------------connect to MySQL Source Host
72
my $dbh = DBI->connect (
"DBI:mysql:host=$sourceHost:port=$sourcePort"
,
73
$sourceUser,
74
$sourcePwd)
75
or die
"Can\'t connect to database: $DBI::errstr\n"
;
76
77
#--------------prepare and execute the query
78
my $sql;
79
if
(!$limit){
80
$sql =
"show databases ;"
;
81
}
else
{
82
$sql =
"show databases like \""
.$limit.
"\" ;"
;
83
}
84
85
my $sth = $dbh->prepare( $sql);
86
87
$sth->execute( );
88
while
( my @row = $sth->fetchrow ){
89
90
my $result = sprintf (
"%s %d %50s %s %d %s"
,$sourceHost.
".internal.sanger.ac.uk"
, $sourcePort, $row[0], $destinationHost.
".internal.sanger.ac.uk "
, $destinationPort, $row[0]);
91
$result .=
" $target_location"
if
$target_location;
92
print $result .
"\n"
;
93
94
}
95
96
$sth->finish( );
ensembl
misc-scripts
CreateFile4CopyDBoverServer.pl
Generated on Mon Sep 29 2025 11:36:43 for ensembl-hive by
1.8.17