check and install new R packages during sgn update... (incase any one is using this...
[sgn-devtools.git] / replace_cxgn_db
blob357bd45b62ee6235362169bcb704329ae8c7312f
1 #!/usr/bin/env perl
3 use strict;
4 use warnings;
5 use autodie qw/:all/;
7 =head1 replace_cxgn_db - replace the local cxgn database
9 Usage:
11 ./replace_cxgn_db
14 ./replace_cxgn_db db.backup.gz
16 =head1 WARNING
18 This will drop your local cxgn database and repopulate it with a backup file. Don't run
19 this command if you have things you want in your local db that are not in the backups!
20 You have been warned.
22 =head1 AUTHOR
24 Jonathan "Duke" Leto
26 =cut
28 my $db_file = shift || 'db.cxgn.pgsql.gz';
30 my $drop_db = "sudo -u postgres dropdb cxgn";
31 my $replace_db = "zcat $db_file | sudo -u postgres psql cxgn";
32 my $new_db = "sudo -u postgres createdb -E SQL_ASCII -T template0 cxgn";
34 die "Cannot find $db_file" unless -e $db_file;
36 print "Going to drop the cxgn database...\n";
37 # We don't care if this fails
38 eval { system $drop_db };
40 print "Going to make a new cxgn database...\n";
41 system $new_db;
43 print "Going to replace the cxgn database...\n";
44 system $replace_db;