From: Will Budic Date: Mon, 24 Feb 2020 03:59:16 +0000 (+1100) Subject: started on backup feature. X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=474cda424356a9a82bacf50adda294130edb2a67;p=LifeLog.git started on backup feature. --- diff --git a/.gitignore b/.gitignore index ef44375..2c1784d 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ htdocs/thttpd.pid htdocs/cgi-bin/wsrc/examples.css dbLifeLog/*.db-journal log/*.log +dbLifeLog/*.db.tgz diff --git a/htdocs/cgi-bin/config.cgi b/htdocs/cgi-bin/config.cgi index 269441f..2139ba3 100755 --- a/htdocs/cgi-bin/config.cgi +++ b/htdocs/cgi-bin/config.cgi @@ -20,6 +20,9 @@ use DateTime::Duration; use Date::Language; use Text::CSV; use Scalar::Util qw(looks_like_number); +use Sys::Syslog qw(:DEFAULT :standard :macros); +use IO::Zlib; +use Archive::Tar; #DEFAULT SETTINGS HERE! use lib "system/modules"; @@ -61,7 +64,10 @@ my $csvp = $cgi->param('csv'); &exportToCSV if ($csvp); -if($cgi->param('data_cat')){ +if($cgi->param('bck')){ + &backup; +} +elsif($cgi->param('data_cat')){ &importCatCSV; }elsif($cgi->param('data_log')){ &importLogCSV; @@ -150,8 +156,8 @@ $tbl = qq(fetchrow_array()) { my $n = $row[1]; next if($n =~ m/^\^/); #skip private tagged settings @@ -271,8 +277,14 @@ while(my @row = $dbs->fetchrow_array()) { ); } - elsif($n ne "RELEASE_VER"){ - $v = ''; + elsif($n eq "RELEASE_VER"){ + $REL = qq( + + ); + next; + } + else{ + $v = ''; } @@ -285,6 +297,7 @@ while(my @row = $dbs->fetchrow_array()) { ); } +$tbl = qq($tbl$REL); #RELEASE VERSION we make outstand last, can't be changed. :) my $frmVars = qq( $tbl @@ -351,6 +364,8 @@ print qq(
$n$v$d
+ + @@ -505,6 +520,13 @@ if($passch){ print "

Client Error: $status

"; } } + + openlog($dsn, 'cons,pid', "user"); + syslog('info', 'Status:%s', $status); + syslog('info', 'Password change request for %s', $$userid); + closelog(); + + } elsif ($change == 1){ @@ -672,6 +694,11 @@ catch{ } + + openlog($dsn, 'cons,pid', "user"); + syslog('info', 'Status:%s', $status); + syslog('err', '%s', $ERROR) if ($ERROR); + closelog(); } sub confirmExistingPass { @@ -894,6 +921,26 @@ sub updCnf { } } +sub backup { + + my $ball = $today->strftime('%Y%m%d%H%M%S_')."$dbname.tgz"; + my $tar = Archive::Tar->new(); + my @fls =(&Settings::logPath.'main.cnf',$database); + $tar-> add_files(@fls); + $tar->write(Settings::logPath().$ball,9); + # Not allowed following for now + # + # print $cgi->header(-type=>"application/octet-stream", -attachment=>"$ball"); + # select(STDOUT); $| = 1; #unbuffer STDOUT + # binmode STDOUT; + # open (TAR, '<', Settings::logPath().$ball); + # print ; + # close TAR; + + LifeLogException->throw("Backup feature currently under development! Serverside created files is -> $ball"); + +} + sub exportToCSV { try{ diff --git a/htdocs/cgi-bin/wsrc/main.js b/htdocs/cgi-bin/wsrc/main.js index a6cc281..9f61fe7 100644 --- a/htdocs/cgi-bin/wsrc/main.js +++ b/htdocs/cgi-bin/wsrc/main.js @@ -976,6 +976,9 @@ function RGBToHex(rgb) { return "#" + r + g + b; } +function fetchBackup() { + window.location = "config.cgi?bck=1"; +} function exportToCSV(dat, view){ var csv;

Backup File Format

CSV File Format

Import Categories: