summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorivan <ivan>2002-10-23 17:07:59 +0000
committerivan <ivan>2002-10-23 17:07:59 +0000
commit1583472a6afefb1ad33e05656fd206674f37d9df (patch)
tree93cae63332e470b853682053cda4fd6a976d09c3 /FS
parent9f96bd19b87cb0084dda17da070f3bb5dadd4823 (diff)
database dump & scp support
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Conf.pm7
-rwxr-xr-xFS/bin/freeside-daily19
2 files changed, 25 insertions, 1 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index b3fffe327..c007a501a 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -989,6 +989,13 @@ httemplate/docs/config.html
'type' => 'checkbox',
},
+ {
+ 'key' => 'dump-scpdest',
+ 'section' => '',
+ 'description' => 'destination for scp database dumps: user@host:/path',
+ 'type' => 'text',
+ },
+
);
1;
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
index 17ee798ff..1db786120 100755
--- a/FS/bin/freeside-daily
+++ b/FS/bin/freeside-daily
@@ -4,8 +4,9 @@ use strict;
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)
@@ -57,6 +58,22 @@ if ( driver_name eq 'Pg' ) {
}
}
+#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 {