Skip to content

Commit 957d312

Browse files
committed
Add backup function
1 parent 64dbad0 commit 957d312

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

ADBOS/Display.pm

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use ADBOS::Email;
1212
use Email::Valid;
1313
use Apache::Solr ();
1414
use Apache::Solr::Document ();
15+
use POSIX qw/strftime/;
1516

1617
my $config = simple_config;
1718
my $db = ADBOS::DB->new($config);
@@ -268,6 +269,15 @@ sub opdef($$$;$)
268269
$self->_standard_template('opdef.html', $vars);
269270
}
270271

272+
sub backup($)
273+
{ my ($self,$req) = @_;
274+
275+
$req->content_type("text/sql; charset=utf-8");
276+
my $date = strftime "%Y%m%d", localtime;
277+
$req->headers_out->add('Content-disposition' => "attachment; filename=$date-adbosbackup-R.sql");
278+
$req->sendfile($config->{backup});
279+
}
280+
271281
sub brief()
272282
{ my ($self, $period, $comments) = @_;
273283

index.pl

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
$display->unparsed($user, $id);
6767
}
6868
}
69+
elsif ($req->unparsed_uri =~ m!^/+backup!gi)
70+
{
71+
$user = $auth->login if !$user;
72+
$display->main($user) unless ($user->{type} eq 'admin');
73+
$display->backup($req);
74+
}
6975
elsif ($req->unparsed_uri =~ m!^/+users/?([0-9]*)!gi)
7076
{
7177
$user = $auth->login if !$user;

0 commit comments

Comments
 (0)