X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=mig-bin%2Fmig-dump;fp=mig-bin%2Fmig-dump;h=0000000000000000000000000000000000000000;hp=57edeab21a1448195516dcfa5ff0b80cc698e933;hb=155eb9eac077ca803f75d1295e584e7012e1b883;hpb=69588457ab8f70fbb77af29cc0653933d24ed2ac diff --git a/mig-bin/mig-dump b/mig-bin/mig-dump deleted file mode 100755 index 57edeab..0000000 --- a/mig-bin/mig-dump +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl - -############################################################################### -=pod - -=head1 NAME - -mig-dump - -A wrapper around the pg_dump command that saves a table in the mig schema with a time stamp in the working directory. - -=head1 SYNOPSIS - -B [arguments...] - -=cut - -############################################################################### - -use strict; -use warnings; - -use Env qw( - HOME PGHOST PGPORT PGUSER PGDATABASE MIGSCHEMA - MIGBASEWORKDIR MIGBASEGITDIR MIGGITDIR MIGWORKDIR -); -use Pod::Usage; -use Switch; -use Cwd 'abs_path'; -use Cwd qw(getcwd); -use FindBin; -my $mig_bin = "$FindBin::Bin/"; -use lib "$FindBin::Bin/"; -use Mig; -use open ':encoding(utf8)'; - -pod2usage(-verbose => 2) if defined $ARGV[0] && $ARGV[0] eq '--help'; -pod2usage(-verbose => 1) if ! $ARGV[1]; - -my $fh; -my $outfile; - -my $table; -my $next_arg_is_table; - -foreach my $arg (@ARGV) { - if ($arg eq '--table') { - $next_arg_is_table = 1; - next; - } - if ($next_arg_is_table) { - $table = $arg; - $next_arg_is_table = 0; - next; - } -} - -my $outfilewpath = create_dumpfile_name($table); - -my $syscmd = 'pg_dump --format plain --data-only --file ' . $outfilewpath . ' --table ' . $MIGSCHEMA . '.' . $table . ' ' . $PGUSER; - -print "pgdump command: \n"; -print "$syscmd\n"; - -system($syscmd); - -####### beyond here be functions - -sub create_dumpfile_name { - my $table_name = shift; - $table_name =~ s/\./_/; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); - $year += 1900; - my $date = $year . '-' . $mon . '-' . $mday; - my $dump_file = $table_name . ' ' . $date . '.pg'; - $dump_file =~ s/ /_/g; - $dump_file = $MIGGITDIR . $dump_file; - print "$dump_file \n"; - return $dump_file; -} - -sub abort { - my $msg = shift; - print STDERR "$0: $msg", "\n"; - exit 1; -} - -