-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdbc_drop
More file actions
executable file
·62 lines (42 loc) · 1.16 KB
/
dbc_drop
File metadata and controls
executable file
·62 lines (42 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl
=head1 SYNOPSIS
dbc_drop [options] mysql-ens-compara-prod-X db_name
=head1 Description
Drop database from ensembl server using db commands
=head1 OPTIONS
=over
=item B<-b[ackup]>
Backup all eHive tables before dropping the database to an SQL.GZ file in the
current working directory (same name as the database).
=item B<-h[elp]>
Print usage information.
=back
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
my $backup = 0;
my $help = 0;
GetOptions(
"b|backup" => \$backup,
"h|help" => \$help,
);
my ($server, $db_name) = @ARGV;
pod2usage(1) if ($help || !($server && $db_name));
my $server_rw;
if ( $server =~ /-eg-/ ) {
$server_rw = "$server-ensrw";
} else {
$server_rw = "$server-ensadmin";
}
my $cmd;
if ($backup) {
$cmd = "standaloneJob.pl Bio::EnsEMBL::Hive::RunnableDB::DatabaseDumper -exclude_list 1 -db_conn \$($server_rw details url)$db_name -output_file ${db_name}.sql.gz &> /dev/null";
print "Backing up eHive tables from $db_name into ${db_name}.sql.gz\n";
system($cmd) == 0
or die "'$cmd' failed: $?";
}
$cmd = "$server_rw -e 'drop database $db_name'";
print "$cmd\n";
system($cmd);