if ( driver_name eq 'Pg' ) {
dbh->{AutoCommit} = 1; #so we can vacuum
- foreach my $statement ( 'vacuum', 'vacuum analyze' ) {
- my $sth = dbh->prepare($statement) or die dbh->errstr;
- $sth->execute or die $sth->errstr;
- }
+ my $sth = dbh->prepare('vacuum analyze') or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
}
-#local hack
my $conf = new FS::Conf;
my $dest = $conf->config('dump-scpdest');
if ( $dest ) {
} else {
die "database dumps not yet supported for ". driver_name;
}
- scp("/var/tmp/$database.sql", $dest);
+ if ( $conf->config('dump-pgpid') ) {
+ eval 'use GnuPG';
+ my $gpg = new GnuPG;
+ $gpg->encrypt( plaintext => "/var/tmp/$database.sql",
+ output => "/var/tmp/$database.gpg",
+ recipient => $conf->config('dump-pgpid'),
+ );
+ chmod 0600, '/var/tmp/$database.gpg';
+ scp("/var/tmp/$database.gpg", $dest);
+ unlink "/var/tmp/$database.gpg" or die $!;
+ } else {
+ chmod 0600, '/var/tmp/$database.sql';
+ scp("/var/tmp/$database.sql", $dest);
+ }
unlink "/var/tmp/$database.sql" or die $!;
}