2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

configdb: code cleanup

git-svn-id: https://svn.fhem.de/fhem/trunk@11497 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
betateilchen 2016-05-22 16:48:43 +00:00
parent afc574626a
commit fa9e708007
2 changed files with 8 additions and 5 deletions

View File

@ -59,17 +59,18 @@ sub CommandConfigdb($$) {
}
when ('dump') {
my $dbtype = _cfgDB_typeInfo();
my ($dbtype,$dbconn) = _cfgDB_typeInfo();
if ($dbtype eq 'SQLITE') {
my $ts = strftime('%Y-%m-%d_%H-%M-%S',localtime);
my $mp = AttrVal('global','modpath','.');
my (undef,$source) = split (/=/, $dbconn);
my $target = "$mp/log/configDB_$ts.dump.gz";
Log3('configdb', 4, "configdb: source for database dump: $source");
Log3('configdb', 4, "configdb: target for database dump: $target");
my $ret = qx(echo '.dump' | sqlite3 /opt/fhem/configDB.db | gzip -c > $target);
my $ret = qx(echo '.dump' | sqlite3 $source | gzip -c > $target);
return $ret if $ret; # return error message if available
my $size = -s $target;
$ret = "configDB dumped $size bytes to file\n$target";
$ret = "configDB dumped $size bytes\nfrom: $source\n to: $target";
# You can use 'zcat $target | sqlite3 configDB.db' in a terminal to restore database.
return $ret;
} else {

View File

@ -821,7 +821,9 @@ sub _cfgDB_Info() {
}
# return database type
sub _cfgDB_typeInfo() { return $cfgDB_dbtype; }
sub _cfgDB_typeInfo() {
return ($cfgDB_dbtype,$cfgDB_dbconn);
}
# recover former config from database archive
sub _cfgDB_Recover($) {