V_7_7/0000755000175000017500000000000013216742320011307 5ustar thomasthomasV_7_7/Haftungsausschluss0000644000175000017500000000272613213236332015134 0ustar thomasthomasHaftungsausschluss: Das von mir geschriebene Programm ExtraBAK (Scriptname = xtbak) ist als Bash-Script nur ein Wrapper für die Linux-Programme tar, rsync, gpg und ftp. Das bedeutet, ExtraBAK erstellt selber keine Backups und hat auch keine eigenen Verschlüsselungs-Algorithmen oder Übertragungsprotokolle implementiert, sondern verwendet zur Erstellung von Archiven oder Datei- Kopien die Programme tar und rsync, sowie gpg zum Verschlüsseln und ftp zum Senden. Ich erhebe keinen Anspruch darauf, dass ExtraBAK vollständig fehlerfrei programmiert ist und ich behaupte das auch nicht. Sowohl durch Programmier- fehler in den 3 Programmen (ExtraBAK, tar und rsync) ist Datenverlust möglich, wie auch durch den Anwender selber verursacht durch unsachgemäße oder fehlerhafte Einstellungen oder falsche Parameterübergaben bei den Programmen. Darüber hinaus ruft ExtraBAK zum Verschlüsseln des Archivs und zum anschließenden Senden via ftp-client weitere Fremdprogramme auf, zu deren Fehlerfreiheit ich ebenfalls keine Aussagen treffen kann. Eine fehler- hafte Verschlüsselung, leicht zu erratende Passphrasen oder ein manipulierter Sendevorgang ermöglichen deshalb vielleicht einen unberechtigten Zugriff durch Dritte auf die Archive. Deshalb schließe ich jede Haftung für Schäden an Software oder Hardware oder Vermögensschäden oder für Datenverlust aus, die durch die Benutzung des Programms ExtraBAK enstehen. Die Benutzung des Programms erfolgt auf eigenes Risiko. V_7_7/usr/0000755000175000017500000000000013204006670012116 5ustar thomasthomasV_7_7/usr/local/0000755000175000017500000000000013204006704013206 5ustar thomasthomasV_7_7/usr/local/bin/0000755000175000017500000000000013213244022013753 5ustar thomasthomasV_7_7/usr/local/bin/xtbak.conf0000644000175000017500000000177113214720241015744 0ustar thomasthomasDescription = SIK conf-files ($HOSTNAME) TargetDirectory = /media/HD2/Backup/ExtraBAK/$HOSTNAME TargetDefaultDirectory = /media/HD2/Backup/ExtraBAK TargetDefaultAltDirectory = /media/HD1/Downloads AddPrefix = RP3 # AddPrefix = $DAY_$MONTH_$YEAR_$DOY_Freetext # AddSuffix = $USER_$HOSTNAME_Freetext AddDate = true # AddHostname = true # AddUsername = true # AddBasename = true # Mount = //172.10.100.2/{ShareName} /media/{ShareName} cifs credentials={CredentialsName},uid=1000,gid=1000,rw Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime # PathLog = /var/log PathLogDefault = /tmp # LogFile = KeepLog = false # MailFrom = xtbak@raspi3 # MailTo = thomas@raspi3 # md5Checksum = true # Verbose = false TestTarfile = true # ContentList = true GpgPassPhrase = GeheimesPWD1234 # GpgKeyID = TomsSecureKey # GpgOutFile = /media/ftpup/rp3.enc FtpHost = www.toml.de FtpUser = toml FtpPwd = toms_secret_password FtpPath = Archive # FtpSendFile = /media/ftpup/rp3.encV_7_7/usr/local/bin/xtbak_Sync.conf0000644000175000017500000000074513214720430016740 0ustar thomasthomasDescription = Sync SSD to HD1 ($HOSTNAME) # Mount = UUID=1234*5678 /media/HD1 ext4 rw,nosuid,nodev,noexec,noatime LogFile = /var/log/DailyLogs_SSDBAK/$DAY.log MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 # verbose = true # simulation = true SyncType = incremental # SyncType = identical sync = /media/SSD/Mail > /media/HD1 SyncIdenticAtDom = 00 sync = /media/SSD/Home > /media/HD1 SyncIdenticAtDom = 02 sync = /media/SSD/Alle > /media/HD1 SyncIdenticAtDom = 03 V_7_7/usr/local/bin/xtbak_Alle.list0000644000175000017500000000002013204073776016726 0ustar thomasthomas/media/SSD/Alle V_7_7/usr/local/bin/xtbak_SDC.xlist0000644000175000017500000000012213203014143016633 0ustar thomasthomas.Trash* Trash* lost+found /dev /home/*/Daten /media /mnt /proc /sys /tmp /var/log V_7_7/usr/local/bin/xtbak.xlist0000644000175000017500000000021513214715373016164 0ustar thomasthomas/etc/alternatives /etc/sane.d /etc/ssl/certs /etc/dbus-1 /etc/dkms /etc/fonts /etc/console-setup /etc/ufw .Trash* Trash* Temp* /home/*/Daten V_7_7/usr/local/bin/xtbak_SDC.conf0000644000175000017500000000051213213245666016441 0ustar thomasthomasDescription = SIK Full-SDC $HOSTNAME Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime TargetDirectory = /media/HD2/Backup/ExtraBAK-SDC adddate = true addprefix = RP3 MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 TestTarfile = false ContentList = false md5checksum = false Verbose = false KeepLog = false V_7_7/usr/local/bin/xtbak_Alle.xlist0000644000175000017500000000004113214715756017123 0ustar thomasthomas.Trash* Trash* Papierkorb* Temp* V_7_7/usr/local/bin/xtbak_Test.list0000644000175000017500000000003113213233760016761 0ustar thomasthomas/usr/local/bin/xTestDirs V_7_7/usr/local/bin/xtbak_Mailserver.conf0000644000175000017500000000034313213727461020141 0ustar thomasthomasDescription = SIK Mailsystem-Confs $HOSTNAME TargetDirectory = /media/HD2/Backup/ExtraBAK addprefix = RP3 adddate = true Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime TestTarfile = true KeepLog = false V_7_7/usr/local/bin/xtbak_Test.xlist0000644000175000017500000000002513102102772017147 0ustar thomasthomas.Trash* Trash* Temp/*V_7_7/usr/local/bin/xtbak_SDC.list0000644000175000017500000000000113110314616016444 0ustar thomasthomas/V_7_7/usr/local/bin/xtbak_Mail.list0000644000175000017500000000002013176323653016733 0ustar thomasthomas/media/SSD/Mail V_7_7/usr/local/bin/xtbak_Mailserver.xlist0000644000175000017500000000007113124447631020354 0ustar thomasthomas.cache .config Daten log .local .ne .ssh oldmail-* *.log V_7_7/usr/local/bin/xTestDirs/0000755000175000017500000000000013213243353015712 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/lost+found/0000755000175000017500000000000013213243353020002 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/sys/0000755000175000017500000000000013213243353016530 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/sys/sys.txt0000644000175000017500000000014512402604363020110 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/.Trash-0/0000755000175000017500000000000013213243353017206 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/.Trash-0/gelöscht.txt0000644000175000017500000000014512402604375022175 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/dev/0000755000175000017500000000000013213243353016470 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/dev/dev.txt0000644000175000017500000000014512402604316020006 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/b/0000755000175000017500000000000013213243353016133 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/b/bb/0000755000175000017500000000000013213243353016516 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/b/bb/b2.txt0000644000175000017500000000014512402604146017562 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/b/b1.txt0000644000175000017500000000014512402604146017176 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/media/0000755000175000017500000000000013213243352016770 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/media/media.txt0000644000175000017500000000014512402604333020607 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/media/.Trash-0/0000755000175000017500000000000013213243352020264 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/media/.Trash-0/gelöscht.txt0000644000175000017500000000014512402604347023253 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/c/0000755000175000017500000000000013213243353016134 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/c/cc/0000755000175000017500000000000013213243353016521 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/c/cc/ccc/0000755000175000017500000000000013213243353017251 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/c/cc/ccc/cccc/0000755000175000017500000000000013213243353020144 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/c/cc/ccc/cccc/c4.txt0000644000175000017500000000014512402604147021214 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/c/cc/ccc/c3.txt0000644000175000017500000000014512402604147020320 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/c/cc/c2.txt0000644000175000017500000000014512402604271017565 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/c/.Trash-0/0000755000175000017500000000000013213243353017430 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/c/c1.txt0000644000175000017500000000014512402604146017200 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/0000755000175000017500000000000013213243353016132 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/a1.txt0000644000175000017500000000014512402603775017203 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/0000755000175000017500000000000013213243353016513 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/sys/0000755000175000017500000000000013213243353017331 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/sys/sys.txt0000644000175000017500000000014512402604205020704 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/media.txt0000644000175000017500000000014512402604146020333 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/dev/0000755000175000017500000000000013213243353017271 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/dev/dev.txt0000644000175000017500000000014512402604146020610 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/media/0000755000175000017500000000000013213243353017572 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/media/media.txt0000644000175000017500000000014512402604146021412 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/media/.Trash-0/0000755000175000017500000000000013213243353021066 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/media/.Trash-0/gelöscht.txt0000644000175000017500000000014512402604236024051 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/media/a2.txt0000644000175000017500000000014512402604146020635 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/a2.txt0000644000175000017500000000014512402604146017556 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xTestDirs/a/aa/aaa/0000755000175000017500000000000013213243353017235 5ustar thomasthomasV_7_7/usr/local/bin/xTestDirs/a/aa/aaa/a3.txt0000644000175000017500000000014512402604146020301 0ustar thomasthomas XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX V_7_7/usr/local/bin/xtbak.list0000644000175000017500000000007113174660055015775 0ustar thomasthomas/etc /usr/local/bin /var/spool/cron/crontabs /home /root V_7_7/usr/local/bin/xtbak_Home.xlist0000644000175000017500000000001713203014107017115 0ustar thomasthomas.Trash* Trash* V_7_7/usr/local/bin/xtbak_Mail.xlist0000644000175000017500000000004713176323664017136 0ustar thomasthomas.Trash* Trash* Papierkorb* Junk* *.msf V_7_7/usr/local/bin/xtbak_Home.conf0000644000175000017500000000057713213517611016723 0ustar thomasthomasDescription = SIK SSD-Home ($HOSTNAME) TargetDirectory = /media/HD2/Backup Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime KeepLog = false MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 md5Checksum = true TestTarfile = true # ContentList = true # Verbose = false GpgOutfile = /media/HD1/Upload/b.enc FtpSendFile = /media/HD1/Upload/b.enc V_7_7/usr/local/bin/xtbak_Test.conf0000644000175000017500000000077413214754771016764 0ustar thomasthomasDescription = SIK conf-files ($HOSTNAME) TargetDirectory = /home/$USER AddPrefix = TPC # AddPrefix = $DAY_$MONTH_$YEAR_$DOY_Freetext # AddSuffix = $USER_$HOSTNAME_Freetext AddDate = true # AddHostname = true # AddUsername = true # AddBasename = true PathLog = /home/$USER KeepLog = true MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 md5Checksum = true TestTarfile = true ContentList = true # Verbose = false GpgOutfile = /home/$USER/test.enc FtpSendFile = /home/$USER/test.enc V_7_7/usr/local/bin/xtbak_Mailserver.list0000644000175000017500000000067313221672312020166 0ustar thomasthomas/etc/postfix /etc/dovecot /etc/radicale /etc/hosts /etc/hostname /etc/fstab /etc/mailname /etc/environment /etc/aliases /etc/systemd/system/radicale-prepare.service /etc/systemd/system/radicale.service /etc/systemd/system/set-iptables.service /usr/local/bin/getmail-eventhandler /usr/local/bin/xtbak_Mailsystem.conf /usr/local/bin/xtbak_Mailsystem.list /usr/local/bin/xtbak_Mailsystem.xlist /home /media/SSD/Mail/Getmail /media/SSD/Mail/Sieve V_7_7/usr/local/bin/xtbak_Home.list0000644000175000017500000000002013176323120016726 0ustar thomasthomas/media/SSD/Home V_7_7/usr/local/bin/xtbak_Alle.conf0000644000175000017500000000057713214755551016720 0ustar thomasthomasDescription = SIK SSD-Alle ($HOSTNAME) TargetDirectory = /media/HD2/Backup Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime KeepLog = false MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 md5Checksum = true TestTarfile = true # ContentList = true # Verbose = false GpgOutfile = /media/HD1/Upload/a.enc FtpSendFile = /media/HD1/Upload/a.enc V_7_7/usr/local/bin/xtbak_Mail.conf0000644000175000017500000000057713213517623016720 0ustar thomasthomasDescription = SIK SSD-Mail ($HOSTNAME) TargetDirectory = /media/HD2/Backup Mount = UUID=5678*1234 /media/HD2 ext4 rw,nosuid,nodev,noexec,noatime KeepLog = false MailFrom = xtbak@raspi3 MailTo = thomas@raspi3 md5Checksum = true TestTarfile = true # ContentList = true # Verbose = false GpgOutfile = /media/HD1/Upload/c.enc FtpSendFile = /media/HD1/Upload/c.enc V_7_7/usr/local/bin/xtbak0000755000175000017500000010415613533164013015027 0ustar thomasthomas#! /bin/bash #============================================================================================================================= # Description : Create Tar-Backup with given Filelist # Script-Name : xtbak (ExtraBAK) # Date : 02.09.2019 # Version : 7.7 # Licence : GNU General Public License 3 # # If this code works, it was # written by : TomL*thlu.de # If not, I don't know who wrote it. ;-) # # ExtraBAK is written and tested for Debian and Raspian # # Dependencies: sendmail (if send a mail is wanted) # md5sum (if checksum is wanted) # gpg (if encrypt Tarfile is wanted) # ftp (if send Tarfile to ftp-server is wanted) # tar # rsync #============================================================================================================================= PATH=/sbin:/usr/sbin:/bin:/usr/bin:$PATH if [[ $EUID -ne 0 ]]; then echo -e "This script should be run as root, otherwise the Backup may be incomplete!\r\n" fi # Init some Var's Separator="=============================================================================================" tStart=0 tEnd=0 Object="" Description="" ConfFile="" IncludeList="" ExcludeList="" TargetDir="" TargetDefaultDir="" TargetDefaultAltDir="" TarfileFullname="" PathLog="" PathLogDefault="" LogFile="" KeepLog=true AddPrefix="" AddSuffix="" AddDate=false AddUsername=false AddHostname=false AddBasename=false Day="" Month="" Year="" md5Checksum=false TestTarfile=false ContentList=false Verbose=true CheckSettings=false MountOrder="" MountPoint="" DoUnmount=false MPNote="" aSyncJobs=() aSyncIdenticAtDom=() SyncType="incremental" Simulation=false MailFrom="" MailTo="" MailText="" GpgPassPhrase="" GpgKeyID="" GpgOutfile="" FtpHost="" FtpUser="" FtpPwd="" FtpPath="" FtpSendFile="" FTPJob="/tmp/xtbak/ftp.job" FTPLog="/tmp/xtbak/ftp.log" FTPPid="/tmp/xtbak/ftp.pid" FTPrc="/tmp/xtbak/ftp.rc" TarErr="/tmp/xtbak/tar.err" aErrorNo=() aErrorTx=( "01: (b) Mount-Versuch fehlgeschlagen!" "02: (b) Mountpoint nicht vorhanden!" "03: (b) Quellverzeichnis nicht vorhanden!" "04: (b) Zielverzeichnis nicht vorhanden!" "05: (b) Ungültiger oder fehlender Dateiname für Tarfile!" "06: (b) Ungültige Include-Filelist angegeben!" "07: (b) Ungültige Exclude-Filelist angegeben!" "08: (b) Keine Include-Filelist angegeben!" "09: (c) Fehlerhafte GPG-Keyid!" "10: (b) Kein Archiv gefunden!" "11: (c) Keine Datei für FTP-Send gefunden!" "12: (c) Keine GPG-Keyid oder Gpg-Passphrase angegeben!" "13: (c) Erstellen Tar-File mit Fehler beendet!" "14: (c) Fehlendes Programm: tar" "15: (c) Fehlendes Programm: rsync" "16: (c) Fehlendes Programm: sendmail / msmtp" "17: (c) Fehlendes Programm: md5sum" "18: (c) Fehlendes Programm: gpg" "19: (c) Fehlendes Programm: ftp!" ) AppTar=$(which tar) AppRsync=$(which rsync) AppMd5=$(which md5sum) AppGpg=$(which gpg) AppFtp=$(which ftp) AppSendmail=$(which sendmail) [ -z "$AppSendmail" ] && AppSendmail=$(which msmtp) [ -z "$AppTar" ] && aErrorNo+=( 14 ) [ -z "$AppRsync" ] && aErrorNo+=( 15 ) [ -z "$AppSendmail" ] && aErrorNo+=( 16 ) [ -z "$AppMd5" ] && aErrorNo+=( 17 ) [ -z "$AppGpg" ] && aErrorNo+=( 18 ) [ -z "$AppFtp" ] && aErrorNo+=( 19 ) #============================================================================================================================ SendMail() { local tmp="" if [ -n "$1" ]; then MailText+="$(date +%d.%m.%Y-%H:%M:%S): $1\r\n" return else [ -z "$MailText" ] && return fi if [ ${#aErrorNo[*]} -gt 0 ]; then MailText+="\r\nFehlermeldungen:\r\n" for i in ${aErrorNo[*]}; do MailText+="${aErrorTx[$i-1]}\r\n" done fi echo "$Separator" >>"$LogFile" echo -e "$MailText" >>"$LogFile" [ -z "$AppSendmail" ] && return if [ -n "$MailTo" ]; then [ -n "$MailFrom" ] && tmp+="From: $MailFrom\r\n" tmp+="To: $MailTo\r\nSubject: xtbak ($Description)\r\n\r\n$(basename $0) - $Description:\r\n$MailText\r\n" echo -e "$tmp\r\n" | $AppSendmail -t $MailTo ### echo -e "$tmp\r\n" | $AppSendmail -t $MailTo --timeout=5 fi } #============================================================================================================================= SendFTP() { local rc=1 [ -z "$AppFtp" ] && return if [ -f "$FtpSendFile" ]; then filepath=$(dirname "$FtpSendFile") filename=$(basename "$FtpSendFile") filesize=$(stat -c%s "$FtpSendFile") blksize=$(( filesize / 100 )) [ $blksize -lt 1000000 ] && blksize=1000000 echo "passive" > $FTPJob echo "open $FtpHost" >> $FTPJob echo "user $FtpUser $FtpPwd" >> $FTPJob echo "lcd $filepath" >> $FTPJob echo "cd $FtpPath" >> $FTPJob echo "hash $blksize" >> $FTPJob echo "put $filename" >> $FTPJob echo "bye" >> $FTPJob ($AppFtp -inv < $FTPJob >$FTPLog) & echo "$!" >"$FTPPid" wait $(cat "$FTPPid") 2> /dev/null rc=$? [ -f "$FTPLog" ] && [ -n "$(grep '226 Transfer completed' -i $FTPLog)" ] && rc=0 [ -f "$FTPJob" ] && rm "$FTPJob" [ -f "$FTPPid" ] && rm "$FTPPid" fi echo $rc >"$FTPrc" return $rc } #============================================================================================================================= CheckErrNoToContinue() { if [ ${#aErrorNo[*]} -gt 0 ]; then for i in ${aErrorNo[*]}; do if [[ "${aErrorTx[$i-1]}" =~ "(b)" ]]; then # (c) = continue, (b) = break SendMail "${aErrorTx[$i-1]}" return 1 fi done fi return 0 } #============================================================================================================================= # Check Plausibilty of Parms and do the Job RunBackup() { local tmp="" local rc=0 [ -z "$AppTar" ] && return [ -z "$TarfileFullname" ] && aErrorNo+=( 5 ) ([ -n "$IncludeList" ] && [ ! -f "$IncludeList" ]) && aErrorNo+=( 6 ) ([ -n "$ExcludeList" ] && [ ! -f "$ExcludeList" ]) && aErrorNo+=( 7 ) [ -z "$IncludeList" ] && aErrorNo+=( 8 ) CheckErrNoToContinue [ $? -eq 1 ] && return echo "$Separator" >>"$LogFile" [ $Verbose == true ] && echo "Create Archiv: $TarfileFullname" ( [ $Verbose == true ] && [ -f "$IncludeList" ] ) && echo "Using $IncludeList" ( [ $Verbose == true ] && [ -f "$ExcludeList" ] ) && echo "Using $ExcludeList" if [ -f "$TarfileFullname" ]; then echo "Info : Tar-File ${TarfileFullname} already exist! Deleted!" >>"$LogFile" rm "$TarfileFullname" fi if [ -f "${TarfileFullname}.md5" ]; then echo "Info : MD5-Checksum ${TarfileFullname}.md5 already exist! Deleted!" >>"$LogFile" rm "$TarfileFullname.md5" fi #------------------------------------------------------------------------------------------------------------------------- SendMail "Create Tarfile started" if [ -n "$ExcludeList" ]; then tmp="Exec : $AppTar -cpz -f ${TarfileFullname} -X ${ExcludeList} -T ${IncludeList}" [ $Verbose == true ] && echo "$tmp" echo "$tmp" >>"$LogFile" $AppTar -cpz -f "${TarfileFullname}" -X "${ExcludeList}" -T "${IncludeList}" 2>$TarErr 1>/dev/null rc=$? else tmp="Exec : $AppTar -cpz -f ${TarfileFullname} -T ${IncludeList}" [ $Verbose == true ] && echo "$tmp" echo "$tmp" >>"$LogFile" $AppTar -cpz -f "${TarfileFullname}" -T "${IncludeList}" 2>$TarErr 1>/dev/null rc=$? fi if [ $rc -ne 0 ]; then tmp="Achtung! $AppTar beendet mit Fehler! (RC=$rc)" echo -e "$Separator\n$tmp\nFehlermeldungen:" >>"$LogFile" cat $TarErr >>"$LogFile" echo "$Separator" >>"$LogFile" [ $Verbose == true ] && echo "$tmp" aErrorNo+=( 13 ) fi [ -f $TarErr ] && rm $TarErr sync SendMail "Create Tarfile done (RC=$rc)" echo "Job: Create Tarfile (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" #------------------------------------------------------------------------------------------------------------------------- if [ -f "$TarfileFullname" ]; then if [ -n "$AppMd5" ]; then if [ $md5Checksum == true ]; then tmp="Exec : $AppMd5 ${TarfileFullname} >${TarfileFullname}.md5" [ $Verbose == true ] && echo "$tmp" echo "$tmp" >>"$LogFile" SendMail "md5checksum started" $AppMd5 "${TarfileFullname}" >"${TarfileFullname}.md5" rc=$? SendMail "md5checksum done (RC=$rc)" echo "Job: md5checksum (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" fi fi #------------------------------------------------------------------------------------------------------------------------- if [ $TestTarfile == true ]; then [ $Verbose == true ] && echo "Start: Test $TarfileFullname" echo "Start: Test $TarfileFullname" >>"$LogFile" SendMail "Test Tarfile started" if [ $ContentList == false ]; then $AppTar -tvf "${TarfileFullname}" >/dev/null else echo "Content $TarfileFullname" >"$LogFile.chktar" $AppTar -tvf "${TarfileFullname}" >>"$LogFile.chktar" fi rc=$? SendMail "Test Tarfile done (RC=$rc)" echo "Job: Test Tarfile (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" fi #------------------------------------------------------------------------------------------------------------------------- if [ -n "$GpgOutfile" ]; then if [ -n "$AppGpg" ]; then if [ -n "$GpgKeyID" ] && [ -z "$($AppGpg --list-keys | grep -w $GpgKeyID)" ]; then aErrorNo+=( 9 ) GpgKeyID="" fi if [ -z "$GpgKeyID" ] && [ -z "$GpgPassPhrase" ]; then aErrorNo+=( 12 ) else if [ -f "$GpgOutfile" ]; then echo "Info : $GpgOutfile already exist! Deleted!" >>"$LogFile" rm "$GpgOutfile" fi SendMail "Encrypt Tarfile started" if [ -n "$GpgPassPhrase" ]; then tmp="Exec : $AppGpg --symmetric --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 --passphrase --batch --yes --output $GpgOutfile $TarfileFullname" else tmp="Exec : $AppGpg --encrypt -a --recipient $GpgKeyID --output $GpgOutfile $TarfileFullname" fi [ $Verbose == true ] && echo "$tmp" echo "$tmp" >>"$LogFile" if [ -n "$GpgPassPhrase" ]; then $AppGpg --symmetric --s2k-cipher-algo AES256 --s2k-digest-algo SHA512 --passphrase "$GpgPassPhrase" --batch --yes --output "$GpgOutfile" "$TarfileFullname" else $AppGpg --encrypt --recipient $GpgKeyID --batch --yes --output "$GpgOutfile" "$TarfileFullname" fi rc=$? tmp=$(file $GpgOutfile) echo "Encr.: $tmp" >>"$LogFile" [ $Verbose == true ] && echo "Encr.: $tmp" SendMail "Encrypt Tarfile done (RC=$rc)" echo "Job: Encrypt Tarfile (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" fi fi fi #------------------------------------------------------------------------------------------------------------------------- if [ -n "$FtpSendFile" ]; then if [ -n "$AppFtp" ]; then if [ -n "$FtpHost" ]; then if [ -f "$FtpSendFile" ]; then tmp="FTP-Send encrypted File" [ $Verbose == true ] && echo "Start: $tmp" echo "Start: $tmp" >>"$LogFile" SendMail "$tmp started" SendFTP & progress=0 blk_send_now=0 blk_send_old=0 cyclefailedcounter=0 [ $(stat -c%s "$FtpSendFile") -lt 100000000 ] && timer=15 || timer=60 echo "Job: sending started, observe transmission process" | systemd-cat -t "thlu:$(basename $0)" -p "info" while true; do sleep $timer [ ! -f $FTPPid ] && break [ ! -f $FTPLog ] && break progress=$(grep "#" $FTPLog) blk_send_now=${#progress} # Anzahl gesendeter Blöcke if [ $blk_send_now -gt $blk_send_old ]; then cyclefailedcounter=0 else (( cyclefailedcounter++ )) echo "Job: Send File (cycle-failed-counter=$cyclefailedcounter)" | systemd-cat -t "thlu:$(basename $0)" -p "info" if [ $cyclefailedcounter -gt 10 ]; then pkill -F $FTPPid break fi fi timer=60 blk_send_old=$blk_send_now echo "Job: transmission seems to be running. blocks send: $blk_send_now" | systemd-cat -t "thlu:$(basename $0)" -p "info" done [ -f "$FTPrc" ] && rc=$(cat "$FTPrc") || rc=999 [ $rc -eq 999 ] && SendMail "$tmp failed (RC=$rc)" || SendMail "$tmp done (RC=$rc)" echo "Job: Send File (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" [ -f $FTPrc ] && rm "$FTPrc" [ -f $FtpSendFile ] && rm "$FtpSendFile" else aErrorNo+=( 11 ) fi fi fi fi #------------------------------------------------------------------------------------------------------------------------- else aErrorNo+=( 10 ) fi } #============================================================================================================================= RunSync() { # read -p "Breakpoint at ?:" local tmp="" local rc=0 [ -z "$AppRsync" ] && return [ $Simulation == true ] && Simulation="-n" || Simulation="" [ "$SyncType" == "identical" ] && SyncType="--delete" || SyncType="" for i in ${!aSyncJobs[*]}; do echo "$Separator" >>"$LogFile" line=${aSyncJobs[$i]} if [[ ${#aSyncIdenticAtDom[*]} -gt 0 ]]; then SyncType="" if [[ "${aSyncIdenticAtDom[$i]}" =~ "$(date +%d)" ]]; then SyncType="--delete" elif [ "${aSyncIdenticAtDom[$i]}" == "00" ]; then SyncType="--delete" fi fi SourceDir=${line%%>*} # links von erstes '>' TargetDir=${line#*>} # rechts von '>' SourceDir=$(echo "$SourceDir" | awk '{$1=$1;print}') # rtrim, ltrim TargetDir=$(echo "$TargetDir" | awk '{$1=$1;print}') if [ ! -d "$SourceDir" ]; then aErrorNo+=( 3 ) elif [ ! -d "$TargetDir" ]; then aErrorNo+=( 4 ) fi CheckErrNoToContinue [ $? -eq 1 ] && return [ -z "$Simulation" ] && tmp="Backup" || tmp="Simulation" echo -e "Perform $tmp: $AppRsync -rlptgouv $Simulation $SyncType $SourceDir $TargetDir\n$Separator" >>"$LogFile" SendMail "rsync $SourceDir started" $AppRsync -rlptgouv $Simulation $SyncType "$SourceDir" "$TargetDir" >>"$LogFile" rc=$? SendMail "rsync done (RC=$rc)" echo "Job: rsync $SourceDir $TargetDir (RC=$rc)" | systemd-cat -t "thlu:$(basename $0)" -p "info" done } #============================================================================================================================= Help() { ahelp=( "Taste Q zum Beenden, mit Pfeiltasten auf und ab scrollen." "" "Usage:" "$(basename $0) { -o NAME -i FILE -e FILE -t PATH -p TEXT -l FILE -s TEXT -b -d -h -u -m -n -5 -c -v -? }" "" "Read Job-Settings from:" "-o = Object-Name (Set Include-, Exclude-, Conf-Filename to Object-Name)" "-i = Filename: Include-Filelist (an excisting File, default $0.list" "-e = Filename: Exclude-Filelist (an excisting File, default $0.xlist" "" "Customize Tarfile-Name:" "-t = Target-Path, where Tarfile be created (an existing Directory" "-p = Add Tarfilename-Prefix (Freetext or Var)" "-s = Add Tarfilename-Suffix (Freetext or Var)" "-b = Add Basename to Tarfile-Name (def=false)" "-d = Add Date to Tarfile-Name (def=false)" "-h = Add Hostname to Tarfile-Name (def=false)" "-u = Add Username to Tarfile-Name (def=false)" "" " 1 Tarfilename allways is generated" "" " 2 TargetDirectory, TargetDefaultDirectory, TargetDefaultAltDirectory in Conf-File contains" " Base-Directories for generated Backup-Tarfile-Name." " Use-Order is left to right, according to the rule: if not exist, then try next one." "" " 3 Allowed Vars are: \$DAY \$MONTH \$YEAR \$USER \$HOSTNAME" "" "Only rsync-Function:" "-n = Not real, perform only rsync-simulation (def=false)" "" "Job-Control-Options:" "-l = Log-Filename (in an existing Directory)" "-k = Keep LogFile = false (def=true)" "-f = Mail from (Sender)" "-m = Send Mail to (Recipient)" "-5 = Create MD5-Checksumfile (def=false)" "-v = Set Verbose-Mode off (def=on) (E.g. Cronjobs)" "-c = Check & Show settings before running" "" " If Log-Filename is not set:" " Usually Logfile is generated with same name like Tarfile-Name with .log as extension." " PathLogDefault + PathLog in Conf-File contains Base-Directories for generated Logfile-Name" " PathLogDefault is used, if PathLog is empty or not exist" " " "-? = Help" "" "Examples:" " xtbak -v" " xtbak -c -n" "" " xtbak -o Home -s 1 -m -v" " xtbak -o Home -t /media/SIK -5 -d" "" " xtbak -o Mail -d -t /media/server/\$HOSTNAME/\$USER" "" ) printf '%s\n' "${ahelp[@]}" | less } #============================================================================================================================= # Jobparameter erkennen oder einlesen [ -f "$0.conf" ] && ConfFile="$0.conf" [ -f "$0.list" ] && IncludeList="$0.list" [ -f "$0.xlist" ] && ExcludeList="$0.xlist" while getopts o:i:e:f:m:t:p:s:l:kbdhnuvc5? opts; do case ${opts} in o) Object=${OPTARG} [ -z "$Object" ] && (echo "Error, no Object is given!"; exit 1) ConfFile="$0_$Object.conf" [ -f "$0_$Object.list" ] && IncludeList="$0_$Object.list" || IncludeList="" [ -f "$0_$Object.xlist" ] && ExcludeList="$0_$Object.xlist" || ExcludeList="" ;; i) IncludeList=${OPTARG};; e) ExcludeList=${OPTARG};; f) MailFrom=${OPTARG};; m) MailTo=${OPTARG};; t) TargetDir=${OPTARG};; p) AddPrefix=${OPTARG};; s) AddSuffix=${OPTARG};; l) LogFile=${OPTARG};; k) KeepLog=false;; b) AddBasename=true;; d) AddDate=true;; h) AddHostname=true;; u) AddUsername=true;; n) Simulation=true;; 5) md5Checksum=true;; c) CheckSettings=true;; v) Verbose=false;; *) Help exit 1 ;; esac done #============================================================================================================================= d=$(date +%d) m=$(date +%m) y=$(date +%Y) t=$(date +%j) tStart=$(date +%s) echo "xtBAK started" | systemd-cat -t "thlu:$(basename $0)" -p "info" for ((n=0;n<2;n++)); do [[ $n -eq 0 ]] && readfrom="$0.conf" || readfrom="$ConfFile" [ $CheckSettings == true ] && ([[ $n -eq 0 ]] && echo "Lese: $readfrom (defaults)" || echo "Lese: $readfrom") if [ ! -f "$readfrom" ]; then [ $CheckSettings == true ] && echo "Fehler: $readfrom nicht gefunden!" exit 1 fi while read line; do [ -n "$line" ] && line=${line%#*} # Links von '#' if [ -n "$line" ];then name=${line%%=*} # links von erstes '=' parm=${line#*=} # rechts von '=' name=${name,,} # lower name=$(echo "$name" | awk '{$1=$1;print}') # rtrim, ltrim parm=$(echo "$parm" | awk '{$1=$1;print}') [ -n "$parm" ] && parm="${parm//'$USER'/${USER}}" # Replace Var $USER durch Username [ -n "$parm" ] && parm="${parm//'$HOSTNAME'/${HOSTNAME}}" # dto. Hostname [ -n "$parm" ] && parm="${parm//'$DAY'/${d}}" # dto. Tag [ -n "$parm" ] && parm="${parm//'$MONTH'/${m}}" # dto. Monat [ -n "$parm" ] && parm="${parm//'$YEAR'/${y}}" # dto. Jahr [ -n "$parm" ] && parm="${parm//'$DOY'/${t}}" # dto. Tag im Jahr [[ "$parm" =~ '/home/root' ]] && parm="${parm//'/home'/}" # replace /home/root durch /root if [ $n -eq 0 ]; then case $name in description) [ -n "$parm" ] && Description=$parm;; # assign non-empty-Values targetdefaultdirectory) [ -n "$parm" ] && TargetDefaultDir=$parm;; targetdefaultaltdirectory) [ -n "$parm" ] && TargetDefaultAltDir=$parm;; pathlogdefault) [ -n "$parm" ] && PathLogDefault=$parm;; gpgpassphrase) [ -n "$parm" ] && GpgPassPhrase=$parm;; gpgkeyid) [ -n "$parm" ] && GpgKeyID=$parm;; ftphost) [ -n "$parm" ] && FtpHost=$parm;; ftpuser) [ -n "$parm" ] && FtpUser=$parm;; ftppwd) [ -n "$parm" ] && FtpPwd=$parm;; ftppath) [ -n "$parm" ] && FtpPath=$parm;; esac else case $name in description) [ -n "$parm" ] && Description=$parm;; # assign non-empty-Values or change defaults pathlog) [ -n "$parm" ] && PathLog=$parm;; addprefix) [ -n "$parm" ] && AddPrefix=$parm;; addsuffix) [ -n "$parm" ] && AddSuffix=$parm;; mailfrom) [ -n "$parm" ] && MailFrom=$parm;; mailto) [ -n "$parm" ] && MailTo=$parm;; mount) [ -n "$parm" ] && MountOrder=$parm;; addbasename) [ "$parm" == "true" ] && AddBasename=true;; adddate) [ "$parm" == "true" ] && AddDate=true;; addusername) [ "$parm" == "true" ] && AddUsername=true;; addhostname) [ "$parm" == "true" ] && AddHostname=true;; md5checksum) [ "$parm" == "true" ] && md5Checksum=true;; testtarfile) [ "$parm" == "true" ] && TestTarfile=true;; contentlist) [ "$parm" == "true" ] && ContentList=true;; verbose) [ "$parm" == "false" ] && Verbose=false;; targetdirectory) [ -n "$parm" ] && TargetDir=$parm;; logfile) [ -n "$parm" ] && LogFile=$parm;; keeplog) [ "$parm" == "false" ] && KeepLog=false;; sync) [ -n "$parm" ] && aSyncJobs+=( "$parm" );; syncidenticatdom) [ -n "$parm" ] && aSyncIdenticAtDom+=( "$parm" ) || aSyncIdenticAtDom+=( "" );; synctype) [ "$parm" == "identical" ] && SyncType="identical";; simulation) [ "$parm" == "true" ] && Simulation=true;; gpgpassphrase) GpgPassPhrase=$parm;; # assign Value or Blank (possibly shall be cleared(?)) gpgkeyid) GpgKeyID=$parm;; # dto. gpgoutfile) [ -n "$parm" ] && GpgOutfile=$parm;; ftphost) [ -n "$parm" ] && FtpHost=$parm;; ftpuser) [ -n "$parm" ] && FtpUser=$parm;; ftppwd) [ -n "$parm" ] && FtpPwd=$parm;; ftppath) [ -n "$parm" ] && FtpPath=$parm;; ftpsendfile) [ -n "$parm" ] && FtpSendFile=$parm;; targetdefaultdirectory) ;; targetdefaultaltdirectory) ;; pathlogdefault) ;; *) [ $CheckSettings == true ] && echo "$name - $parm = nicht gefunden";; esac fi fi done < <(cat $readfrom; echo "") done if [ -n "$MountOrder" ]; then mdev=$(awk -F ' ' '{ print $1 }' <<< $MountOrder) mpnt=$(awk -F ' ' '{ print $2 }' <<< $MountOrder) mtyp=$(awk -F ' ' '{ print $3 }' <<< $MountOrder) mopt=$(awk -F ' ' '{ print $4 }' <<< $MountOrder) if [ -z "$(cat /proc/mounts | grep $mpnt)" ]; then if [ -d "$mpnt" ]; then mount "$mdev" "$mpnt" -t "$mtyp" -o "$mopt" rc=$? if [ $rc -eq 0 ]; then MountPoint="$mpnt" DoUnmount=true else MountPoint="$mdev" MPNote="(Error: mount failed!)" aErrorNo+=( 1 ) fi else MountPoint="$mpnt" MPNote="(Error: mountpoint not exist!)" aErrorNo+=( 2 ) fi else MountPoint="$mpnt" MPNote="(Note: already mounted!)" fi fi TarfileFullname="" if [ -n "$AddPrefix" ]; then TarfileFullname="$AddPrefix" fi if [ $AddBasename == true ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$(basename $0)" fi if [ -n "$Object" ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$Object" fi if [ $AddHostname == true ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$HOSTNAME" fi if [ $AddUsername == true ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$USER" fi if [ $AddDate == true ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$(date +%y%m%d)" fi if [ -n "$AddSuffix" ]; then [ -n "$TarfileFullname" ] && TarfileFullname+="_" TarfileFullname+="$AddSuffix" fi [ -z "$TarfileFullname" ] && TarfileFullname=$(basename $0) [ -n "$MailTo" ] && [ -z $AppSendmail ] && MailTo="$MailTo (Failed: Mail-App not found!)" if [ -n "$LogFile" ]; then [ ! -d "$(dirname $LogFile)" ] && mkdir -p "$(dirname $LogFile)" [ ! -d "$(dirname $LogFile)" ] && LogFile="" fi if [ -z "$LogFile" ]; then tmp="" [ -z "$tmp" ] && [ -n "$PathLog" ] && [ -d "$PathLog" ] && tmp="$PathLog" [ -z "$tmp" ] && [ -n "$PathLogDefault" ] && [ -d "$PathLogDefault" ] && tmp="$PathLogDefault" [ -z "$tmp" ] && tmp="/tmp/xtbak" LogFile="$tmp/$TarfileFullname.log" fi [ -f "$LogFile" ] && rm "$LogFile" touch "$LogFile" tmp="" [ -n "$TargetDir" ] && [ -d "$TargetDir" ] && tmp="$TargetDir" [ -z "$tmp" ] && [ -n "$TargetDefaultDir" ] && [ -d "$TargetDefaultDir" ] && tmp="$TargetDefaultDir" [ -z "$tmp" ] && [ -n "$TargetDefaultAltDir" ] && [ -d "$TargetDefaultAltDir" ] && tmp="$TargetDefaultAltDir" [ -n "$tmp" ] && TarfileFullname="$tmp/$TarfileFullname.tgz" || TarfileFullname="" echo -e "\n$(date +%d.%m.%Y-%H:%M) \n$Separator">>"$LogFile" tmp="" [ -n "$GpgKeyID" ] && tmp="RSA2048" [ -n "$GpgPassPhrase" ] && tmp="AES256" if [ ${#aSyncJobs[*]} -eq 0 ]; then echo -e\ "Description : $Description"\ "\nStarted as UID (0=root) : $EUID"\ "\nObject : $Object"\ "\nConfFile used : $ConfFile"\ "\nIncludeList used : $IncludeList"\ "\nExcludeList used : $ExcludeList"\ "\nVerbose : $Verbose"\ "\nAdd Prefix : $AddPrefix"\ "\nAdd Basename : $AddBasename"\ "\nAdd Hostname : $AddHostname"\ "\nAdd Username : $AddUsername"\ "\nAdd Date : $AddDate"\ "\nAdd Suffix : $AddSuffix"\ "\nCreate md5Checksum : $md5Checksum"\ "\nTest Tarfile : $TestTarfile"\ "\nContentList : $ContentList"\ "\nMountorder : $MountOrder"\ "\nMountpoint : $MountPoint $MPNote"\ "\nDo umount : $DoUnmount"\ "\nLogDirDefault : $PathLogDefault"\ "\nLogDir : $PathLog"\ "\nLog-File : $LogFile"\ "\nKeep Log-File : $KeepLog"\ "\nMail from : $MailFrom"\ "\nMail to : $MailTo"\ "\nGPG Encrypt Tarfile to : $GpgOutfile"\ "\nEncryption : $tmp"\ "\nSend Enc-Tarfile to Host: $FtpHost"\ "\nSend File : $FtpSendFile"\ "\nTargetDir : $TargetDir"\ "\nTargetDefaultDir : $TargetDefaultDir"\ "\nTargetDefaultAltDir : $TargetDefaultAltDir"\ "\nCreate Tarfile : $TarfileFullname"\ >>"$LogFile" else for i in ${!aSyncJobs[*]}; do echo -e "Sync $i \t\t\t: ${aSyncJobs[$i]}" >>"$LogFile" [[ ${#aSyncIdenticAtDom[*]} -gt 0 ]] && echo -e "Identical at DOM\t: ${aSyncIdenticAtDom[$i]}" >>"$LogFile" done echo -e\ "\nDescription : $Description"\ "\nStarted as UID (0=root) : $EUID"\ "\nMountorder : $MountOrder"\ "\nMountpoint : $MountPoint $MPNote"\ "\nDo umount : $DoUnmount"\ "\nSimulation : $Simulation"\ "\nSyncType : $SyncType"\ "\nMail from : $MailFrom"\ "\nMail to : $MailTo"\ "\nVerbose : $Verbose"\ "\nLogDirDefault : $PathLogDefault"\ "\nLogDir : $PathLog"\ "\nLog-File : $LogFile"\ >>"$LogFile" fi response="j" if [ $CheckSettings == true ]; then cat "$LogFile" echo "$Separator" read -p "Backup starten (j/n)? " response echo "" fi #============================================================================================================================= # read -p "Breakpoint at ?: $response" if [[ "Jj" =~ "$response" ]]; then CheckErrNoToContinue if [ $? -eq 0 ]; then mkdir -p "/tmp/xtbak" if [ ${#aSyncJobs[*]} -eq 0 ]; then RunBackup else RunSync fi fi fi #============================================================================================================================= sync if [ -f "$FTPLog" ]; then echo "$Separator" >>"$LogFile" cat "$FTPLog" >>"$LogFile" echo "" >>"$LogFile" rc=$(grep -i "goodbye" "$FTPLog") SendMail "FTP-Send $rc" rm "$FTPLog" fi [ $DoUnmount == true ] && umount "$MountPoint" if [ -n "$MountPoint" ]; then if [ -n "$(cat /proc/mounts | grep $MountPoint)" ]; then echo "$MountPoint is still mounted!" | systemd-cat -t "thlu:$(basename $0)" -p "info" SendMail "$MountPoint is still mounted!" else echo "$MountPoint successful umounted" | systemd-cat -t "thlu:$(basename $0)" -p "info" SendMail "$MountPoint is not mounted or successful umounted" fi fi SendMail if [ -f "$LogFile.chktar" ]; then echo "$Separator" >>"$LogFile" cat "$LogFile.chktar" >>"$LogFile" rm "$LogFile.chktar" fi tEnd=$(date +%s) tDiff=$((tEnd-tStart)) echo "xtBAK finished, after $tDiff Runtime-Seconds" | systemd-cat -t "thlu:$(basename $0)" -p "info" [ $Verbose == true ] && [[ "Jj" =~ "$response" ]] && less -S "$LogFile" [ $KeepLog == false ] && rm "$LogFile" CheckErrNoToContinue if [ $? -eq 1 ]; then exit 1 fi exit 0 #============================================================================================================================= #End