From eb7b661058a140d4caf0b995049aad01d11316d0 Mon Sep 17 00:00:00 2001 From: Marko Oldenburg Date: Thu, 21 Feb 2019 09:38:29 +0100 Subject: [PATCH] first implementaton of systembackup --- backupME.conf | 8 +++++++- backupME.pl | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/backupME.conf b/backupME.conf index f5bc340..656c829 100644 --- a/backupME.conf +++ b/backupME.conf @@ -1,4 +1,4 @@ -### Konfiguration +### Konfiguration für ein einfaches Backup # wie soll das Verzeichnis heißen wo die Backups hin geschrieben werden BACKUPDIRNAME=fhem_backups @@ -55,3 +55,9 @@ DBNAMES=fhemLogHistory # wo soll der Dump hingeschrieben werden DBBACKUPPATH=/opt/fhem/backup + + + +### Konfiguration für ein einfaches Backup +# in welches Verzeichnis soll das Systembackupfile hingeschrieben werden +SYSTEMBACKUPDIRNAME= diff --git a/backupME.pl b/backupME.pl index ff9f6a2..d3890e9 100755 --- a/backupME.pl +++ b/backupME.pl @@ -53,6 +53,7 @@ sub createDBdump; sub runBackup($); sub _sendStateToFHEM($); sub checkSendFHEMConnect($); +sub MainSystemBackup; ################################################## # Variables: @@ -65,8 +66,10 @@ my $self = {}; my ($conffile,$debug,$acount); $debug = 0; -my @conffiles = split(/,/,parseOptions); +my ($conffilestring,$mode) = parseOptions; +my @conffiles = split(/,/,$conffilestring); $self->{configfiles} = \@conffiles; +$self->{mode} = $mode; $self->{config}->{TARCMDPATH} = qx(which tar); chomp($self->{config}->{TARCMDPATH}); @@ -75,12 +78,13 @@ unless ( defined($self->{config}->{TARCMDPATH}) and $self->{config}->{TARCMDPATH exit 1; } -MainBackup; +MainBackup if ( $self->{mode} eq 'backup' ); +MainSystemBackup if ( $self->{mode} eq 'system' ); exit 0; -##### SUBS #### +##### SUBS for Backup #### sub MainBackup { @@ -258,22 +262,25 @@ sub readConfigFile { sub parseOptions { my $conffiles = undef; + my $mode = 'backup'; GetOptions( - 'configfiles|configs|c=s' => \$conffiles, + 'backupMode|mode|m=s' => \$mode, + 'configfiles|configs|c=s' => \$conffiles ) or usageExit; - usageExit unless ( defined($conffiles) ); + $mode =~ m/^backup|system$/ or usageExit; + defined($conffiles) or usageExit; - return ($conffiles); + return ($conffiles,$mode); } sub usageExit { print('usage:' . "\n"); - printf("\t" . '-c , ...' . "\n"); - printf("\t" . '-configs , ...' . "\n"); - printf("\t" . '--configfiles , ...' . "\n"); + printf("\t" . '-c ,... -m ' . "\n"); + printf("\t" . '-configs ,... -mode ' . "\n"); + printf("\t" . '--configfiles , ...--backupMode ' . "\n"); exit(1); } @@ -323,6 +330,18 @@ sub createBackUpPathStructs($) { return $state; } + +##### SUBS for Systembackup #### + + +sub MainSystemBackup { + + + +} + +##### SUBS for FHEM #### + sub checkSendFHEMConnect($) { my $fnState = shift;