use Fcntl qw(:flock);
use Date::Parse;
use Getopt::Std;
-use FS::UID qw(adminsuidsetup driver_name dbh);
+use FS::UID qw(adminsuidsetup driver_name dbh datasrc);
use FS::Record qw(qsearch qsearchs);
+use FS::Conf;
use FS::cust_main;
&untaint_argv; #what it sounds like (eww)
# $^T not $time because -d is for pre-printing invoices
foreach my $cust_pkg (
- grep { $_->expire && $_->expire >= $^T } $cust_main->ncancelled_pkgs
+ grep { $_->expire && $_->expire <= $^T } $cust_main->ncancelled_pkgs
) {
my $error = $cust_pkg->cancel;
warn "Error cancelling expired pkg ". $cust_pkg->pkgnum. " for custnum ".
}
}
+#local hack
+my $conf = new FS::Conf;
+my $dest = $conf->config('dump-scpdest');
+if ( $dest ) {
+ datasrc =~ /dbname=([\w\.]+)$/ or die "unparsable datasrc ". datasrc;
+ my $database = $1;
+ eval "use Net::SCP qw(scp);";
+ if ( driver_name eq 'Pg' ) {
+ system("pg_dump $database >/var/tmp/$database.sql")
+ } else {
+ die "database dumps not yet supported for ". driver_name;
+ }
+ scp("/var/tmp/$database.sql", $dest);
+ unlink "/var/tmp/$database.sql" or die $!;
+}
+
# subroutines
sub untaint_argv {