From: Mario Höllein Date: Fri, 22 Nov 2019 07:53:45 +0000 (+0100) Subject: deleted and ignored X-Git-Url: https://git.hoellein.online/?a=commitdiff_plain;h=0dfc6c847b98e8f02cf5911086f7bb3ab934ed89;p=zenbook_bin deleted and ignored --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea6c4ef --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Ultimaker_Cura-4.2.1.AppImage diff --git a/backup_Bilder.sh b/backup_Bilder.sh index 7c9d002..b46a209 100755 --- a/backup_Bilder.sh +++ b/backup_Bilder.sh @@ -1,3 +1,45 @@ #!/bin/bash +SCRIPTNAME=${0##*/} + +#if [ -z "$STY" ]; then exec screen -dm -S $SCRIPTNAME /bin/bash "$0"; fi + BACKUP_DIR="/home/mhoellein/Bilder/ .local/share/shotwell/" -borg create --stats ssh://borg@vserver2.hoellein.online:22/home/borg/Bilder::$(date +%Y-%m-%d_%H:%m) ${BACKUP_DIR} +TMPFILE="/tmp/$SCRIPTNAME.$(date +%Y%m%d).log" +LOGFILE="/var/log/$SCRIPTNAME.$(date +%Y%m%d).log" +function infomsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") INFO $1" +} + +function errormsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") ERROR $1" +} + +function debugmsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") DEBUG $1" +} +function cattmpfile2info(){ + cat $TMPFILE | while read L; do infomsg "$L"; done + rm -f $TMPFILE +} +function cattmpfile2debug(){ + cat $TMPFILE | while read L; do debugmsg "$L"; done + rm -f $TMPFILE +} + +infomsg "###### Backup gestartet ######################################################" +infomsg "Running $BASEDIR/$SCRIPTNAME" + +infomsg "##############################################################################" + +infomsg "Übertrage Dateien aus ${BACKUP_DIR} ..." + + +#borg create --stats ssh://borg@vserver2.hoellein.online:22/home/borg/Bilder::$(date +%Y-%m-%d_%H:%m) ${BACKUP_DIR} >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +echo test >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +ret=$? +cattmpfile2info + +sleep 5 +cat $LOGFILE >> /var/log/$SCRIPTNAME.log +rm -f $LOGFILE + diff --git a/backup_with_borg b/backup_with_borg new file mode 100755 index 0000000..516b24b --- /dev/null +++ b/backup_with_borg @@ -0,0 +1,342 @@ +#!/bin/bash + +SCRIPTNAME=${0##*/} + +if [ -z "$STY" ]; then exec screen -dm -S $SCRIPTNAME /bin/bash "$0"; fi + +[ "${FLOCKER}" != "$0" ] && exec env FLOCKER="$0" flock -en "$0" "$0" "$@" || : + +BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +LOGFILE="/var/log/$SCRIPTNAME.$(date +%Y%m%d).log" +TMPFILE="/tmp/$SCRIPTNAME.$(date +%Y%m%d).log" + +BACKUPDEVICE=/dev/mapper/$(LANG=de_DE date +\%A) +DEST=/backup + +if [ ! -e $BACKUPDEVICE ]; then + mail -S sendcharsets=UTF-8 -S encoding=8bit -s "$(hostname): Protokoll $SCRIPTNAME kein Backupziel gefunden" -r $MAILFROM $MAILCC $MAILTO <&1 4>&2 +exec 1> >(tee -i -a ${LOGFILE}) 2>&1 + +function infomsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") INFO $1" +} + +function errormsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") ERROR $1" +} + +function debugmsg(){ + echo "$(date +"%Y/%m/%d %H:%M:%S") DEBUG $1" +} +function cattmpfile2info(){ + cat $TMPFILE | while read L; do infomsg "$L"; done + rm -f $TMPFILE +} +function cattmpfile2debug(){ + cat $TMPFILE | while read L; do debugmsg "$L"; done + rm -f $TMPFILE +} + +declare -a HOSTS +declare -a STATUS + +infomsg "###### Backup gestartet ######################################################" +infomsg "Running $BASEDIR/$SCRIPTNAME" + +infomsg "##############################################################################" +host="vis-virtserv2" +infomsg "Übertrage Dateien $host ..." +borg create --stats $DEST/vis-virtserv2::'{now:%Y-%m-%d_%H:%M}' \ + / \ + --exclude /proc/ \ + --exclude /sys/ \ + --exclude /dev/ \ + --exclude '/var/lib/*/proc/' \ + --exclude /var/run/ \ + --exclude /run/ \ + --exclude /backup/ \ + --exclude /virtbackup/ \ + --exclude /var/lib/libvirt/images/ \ + --exclude '/home/*/.cache' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +ret=$? +cattmpfile2info +infomsg "Übertrage Dateien $host ret=$ret" + +HOSTS=("$host" "${HOSTS[@]}") +STATUS=("$ret" "${STATUS[@]}") +[ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + +borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/vis-virtserv2 >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +ret=$? +cattmpfile2info +infomsg "Aufräumen $host ret=$ret" + + +infomsg "##############################################################################" +host="lkw-caps" +/usr/bin/guest_snapshot_mount -h lkw-caps -g VGsystem -l LVlkw-caps -s 10G -p 0 vg_lkw--caps-root:/ 1:/boot vg_lkw--caps-var:/var vg_lkw--caps-home:/home vg_lkw--caps-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +if [ -e /virtbackup/./$host/etc/os-release ]; then + infomsg "Übertrage Dateien $host ..." + borg create --stats $DEST/$host::'{now:%Y-%m-%d_%H:%M}' \ + /virtbackup/./lkw-caps \ + --exclude /virtbackup/./lkw-caps/proc/ \ + --exclude /virtbackup/./lkw-caps/sys/ \ + --exclude /virtbackup/./lkw-caps/dev/ \ + --exclude '/virtbackup/./lkw-caps/var/lib/*/proc/' \ + --exclude /virtbackup/./lkw-caps/var/run/ \ + --exclude /virtbackup/./lkw-caps/run/ \ + --exclude /virtbackup/./lkw-caps/mnt/ \ + --exclude /virtbackup/./lkw-caps/tmp/ \ + --exclude /virtbackup/./lkw-caps/var/tmp/ \ + --exclude '/virtbackup/./lkw-caps/backup*/' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Übertrage Dateien $host ret=$ret" + + HOSTS=("$host" "${HOSTS[@]}") + STATUS=("$ret" "${STATUS[@]}") + [ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + + borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/lkw-caps >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Aufräumen $host ret=$ret" + +else + errormsg "Gast $host nicht gemountet." +fi +/usr/bin/guest_snapshot_umount -h lkw-caps -g VGsystem -l LVlkw-caps -s 10G -p 0 vg_lkw--caps-root:/ 1:/boot vg_lkw--caps-var:/var vg_lkw--caps-home:/home vg_lkw--caps-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug + +infomsg "##############################################################################" +host="evk-cs" +/usr/bin/guest_snapshot_mount -h evk-cs -g VGsystem -l LVevk-cs-123 -s 10G -p 0 vg_evk--cs-root:/ 1:/boot vg_evk--cs-home:/home vg_evk--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +if [ -e /virtbackup/./$host/etc/os-release ]; then + infomsg "Übertrage Dateien $host ..." + borg create --stats $DEST/evk-cs::'{now:%Y-%m-%d_%H:%M}' \ + /virtbackup/./evk-cs \ + --exclude /virtbackup/./evk-cs/proc/ \ + --exclude /virtbackup/./evk-cs/sys/ \ + --exclude /virtbackup/./evk-cs/dev/ \ + --exclude '/virtbackup/./evk-cs/var/lib/*/proc/' \ + --exclude /virtbackup/./evk-cs/var/run/ \ + --exclude /virtbackup/./evk-cs/run/ \ + --exclude /virtbackup/./evk-cs/mnt/ \ + --exclude /virtbackup/./evk-cs/tmp/ \ + --exclude /virtbackup/./evk-cs/var/tmp/ \ + --exclude '/virtbackup/./evk-cs/backup*/' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Übertrage Dateien $host ret=$ret" + + HOSTS=("$host" "${HOSTS[@]}") + STATUS=("$ret" "${STATUS[@]}") + [ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + + borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/evk-cs >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Aufräumen $host ret=$ret" + +else + errormsg "Gast $host nicht gemountet." +fi +/usr/bin/guest_snapshot_umount -h evk-cs -g VGsystem -l LVevk-cs-123 -s 10G -p 0 vg_evk--cs-root:/ 1:/boot vg_evk--cs-home:/home vg_evk--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug + +infomsg "##############################################################################" +host="lkw-cs" +/usr/bin/guest_snapshot_mount -h lkw-cs -g VGsystem -l LVlkw-cs-123 -s 10G -p 0 vg_lkw--cs-root:/ 1:/boot vg_lkw--cs-home:/home vg_lkw--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +if [ -e /virtbackup/./lkw-cs/etc/os-release ]; then + infomsg "Übertrage Dateien $host ..." + borg create --stats $DEST/lkw-cs::'{now:%Y-%m-%d_%H:%M}' \ + /virtbackup/./lkw-cs \ + --exclude /virtbackup/./lkw-cs/proc/ \ + --exclude /virtbackup/./lkw-cs/sys/ \ + --exclude /virtbackup/./lkw-cs/dev/ \ + --exclude '/virtbackup/./lkw-cs/var/lib/*/proc/' \ + --exclude /virtbackup/./lkw-cs/var/run/ \ + --exclude /virtbackup/./lkw-cs/run/ \ + --exclude /virtbackup/./lkw-cs/mnt/ \ + --exclude /virtbackup/./lkw-cs/tmp/ \ + --exclude /virtbackup/./lkw-cs/var/tmp/ \ + --exclude '/virtbackup/./lkw-cs/backup*/' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Übertrage Dateien $host ret=$ret" + + HOSTS=("$host" "${HOSTS[@]}") + STATUS=("$ret" "${STATUS[@]}") + [ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + + borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/lkw-cs >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Aufräumen $host ret=$ret" + +else + errormsg "Gast $host nicht gemountet." +fi +/usr/bin/guest_snapshot_umount -h lkw-cs -g VGsystem -l LVlkw-cs-123 -s 10G -p 0 vg_lkw--cs-root:/ 1:/boot vg_lkw--cs-home:/home vg_lkw--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug + +infomsg "##############################################################################" +host="gsw-cs" +/usr/bin/guest_snapshot_mount -h gsw-cs -g VGsystem -l LVgsw-cs-123 -s 10G -p 0 vg_gsw--cs-root:/ 1:/boot vg_gsw--cs-home:/home vg_gsw--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +if [ -e /virtbackup/./gsw-cs/etc/os-release ]; then + infomsg "Übertrage Dateien $host ..." + borg create --stats $DEST/gsw-cs::'{now:%Y-%m-%d_%H:%M}' \ + /virtbackup/./gsw-cs \ + --exclude /virtbackup/./gsw-cs/proc/ \ + --exclude /virtbackup/./gsw-cs/sys/ \ + --exclude /virtbackup/./gsw-cs/dev/ \ + --exclude '/virtbackup/./gsw-cs/var/lib/*/proc/' \ + --exclude /virtbackup/./gsw-cs/var/run/ \ + --exclude /virtbackup/./gsw-cs/run/ \ + --exclude /virtbackup/./gsw-cs/mnt/ \ + --exclude /virtbackup/./gsw-cs/tmp/ \ + --exclude /virtbackup/./gsw-cs/var/tmp/ \ + --exclude '/virtbackup/./gsw-cs/backup*/' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Übertrage Dateien $host ret=$ret" + + HOSTS=("$host" "${HOSTS[@]}") + STATUS=("$ret" "${STATUS[@]}") + [ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + + borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/gsw-cs >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Aufräumen $host ret=$ret" + +else + errormsg "Gast $host nicht gemountet." +fi +/usr/bin/guest_snapshot_umount -h gsw-cs -g VGsystem -l LVgsw-cs-123 -s 10G -p 0 vg_gsw--cs-root:/ 1:/boot vg_gsw--cs-home:/home vg_gsw--cs-swap:ignore >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug + +infomsg "##############################################################################" +host="vis-archiv" +/usr/bin/guest_snapshot_mount -h vis-archiv -g VGsystem -l LVvis-archiv-system-123 -s 10G -p 0 2:/ >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +/usr/bin/guest_snapshot_mount -h vis-archiv -g VGsystem -l LVvis-archiv-home-123 -s 300G -p 0 1:/home >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +if [ -e /virtbackup/./vis-archiv/etc/os-release ]; then + infomsg "Übertrage Dateien $host ..." + borg create --stats $DEST/vis-archiv::'{now:%Y-%m-%d_%H:%M}' \ + /virtbackup/./vis-archiv \ + --exclude /virtbackup/./vis-archiv/proc/ \ + --exclude /virtbackup/./vis-archiv/sys/ \ + --exclude /virtbackup/./vis-archiv/dev/ \ + --exclude '/virtbackup/./vis-archiv/var/lib/*/proc/' \ + --exclude /virtbackup/./vis-archiv/var/run/ \ + --exclude /virtbackup/./vis-archiv/run/ \ + --exclude /virtbackup/./vis-archiv/mnt/ \ + --exclude /virtbackup/./vis-archiv/tmp/ \ + --exclude /virtbackup/./vis-archiv/var/tmp/ \ + --exclude '/virtbackup/./vis-archiv/backup*/' \ + --exclude '/virtbackup/./vis-archiv/home/modarch3_vis_q*/' \ + --exclude /virtbackup/./vis-archiv/home/postgres/backups/ \ + --exclude /virtbackup/./vis-archiv/home/postgres/data/ \ + --exclude /virtbackup/./vis-archiv/home/postgres/pg_xlog/ \ + --exclude /virtbackup/./vis-archiv/home/modarch/docroot/sessions/ \ + --exclude /virtbackup/./vis-archiv/home/modarch/cache/ \ + --exclude '/virtbackup/./vis-archiv/home/*/.cache/' \ + --exclude '/virtbackup/./vis-archiv/home/*/mounts/' \ + --exclude '/virtbackup/./vis-archiv/home/*/tmp/' \ + --exclude '/virtbackup/./vis-archiv/home/*/var/tmp/' \ + --exclude '/virtbackup/./vis-archiv/home/*/var/lock/' \ + --exclude '/virtbackup/./vis-archiv/home/*/var/cache/' \ + --exclude '/virtbackup/./vis-archiv/home/*/var/sessions/' \ + --exclude '/virtbackup/./vis-archiv/home/*/import-done/' \ + --exclude '/virtbackup/./vis-archiv/home/*/backup/' \ + --exclude '/virtbackup/./vis-archiv/home/*/media/sessions/' \ + --exclude '/virtbackup/./vis-archiv/home/*/src/' \ + --exclude '*.attachments_scaled' \ + --exclude '*.scaled' >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + # --exclude /virtbackup/./vis-archiv/home/modarch/incomming/ \ + cattmpfile2info + infomsg "Übertrage Dateien $host ret=$ret" + + HOSTS=("$host" "${HOSTS[@]}") + STATUS=("$ret" "${STATUS[@]}") + [ -x bin/post_borg_backup ] && bin/post_borg_backup $host $ret + + borg prune --keep-daily=7 --keep-weekly=4 --keep-monthly=12 $DEST/vis-archiv >>$TMPFILE 2> >( tee -a $TMPFILE >&2) + ret=$? + cattmpfile2info + infomsg "Aufräumen $host ret=$ret" + +else + errormsg "Gast $host nicht gemountet." +fi +/usr/bin/guest_snapshot_umount -h vis-archiv -g VGsystem -l LVvis-archiv-home-123 -s 300G -p 0 1:/home >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug +/usr/bin/guest_snapshot_umount -h vis-archiv -g VGsystem -l LVvis-archiv-system-123 -s 10G 2:/ >>$TMPFILE 2> >( tee -a $TMPFILE >&2) +cattmpfile2debug + +infomsg "###### Backup beendet ########################################################" + +umount $DEST && /usr/sbin/cryptsetup --batch-mode close $BACKUPDEVICE + +exec 1>&3 2>&4 + +if [ -n "$MAILTO" ]; then + MAILINHALT="\n" + OKSUM=0 + ERRSUM=0 + for i in $(seq 0 $((${#HOSTS[@]}-1))); do + if [ ${STATUS[$i]} -eq 0 ]; then + let OKSUM++ + MAILINHALT=$(echo -e "$MAILINHALT\n ${HOSTS[$i]} ok") + else + let ERRSUM++ + MAILINHALT=$(echo -e "$MAILINHALT\n ${HOSTS[$i]} nicht ok") + fi + done + mail -S sendcharsets=UTF-8 -S encoding=8bit -s "$(hostname): Protokoll $SCRIPTNAME $OKSUM/${#HOSTS[@]} gesichert, $ERRSUM Fehler" -a $LOGFILE -r $MAILFROM $MAILCC $MAILTO <> /var/log/$SCRIPTNAME.log +rm -f $LOGFILE diff --git a/createSSHPubFromTrezorConfig.sh b/createSSHPubFromTrezorConfig.sh new file mode 100755 index 0000000..de643d6 --- /dev/null +++ b/createSSHPubFromTrezorConfig.sh @@ -0,0 +1,31 @@ +#!/bin/bash +#set -x + +die(){ + echo "$$: $1" + echo "$$: exit" + exit 1 +} +$(lsusb|grep "TREZOR" >/dev/null) +[ $? -eq 0 ] || die "kein TREZOR erkannt" + +IDENTITY="" +USER="" +HOST="" +SSH_PATH="/home/mhoellein/.ssh" + + +while read line +do + IDENTITY=`echo $line|sed -e "s-^ ${SSH_PATH}/${IDENTITY}.pub 2>/dev/null + echo "host $HOST" + echo -e "User $USER" + echo -e "\tIdentityFile ~/.ssh/${IDENTITY}.pub" + echo "" + fi +done < ${SSH_PATH}/trezor.conf diff --git a/remailbackupplatte b/remailbackupplatte new file mode 100644 index 0000000..0ecc8e8 --- /dev/null +++ b/remailbackupplatte @@ -0,0 +1,21 @@ +#!/bin/bash +# Prüft ob in den letzte 4 Stunden eine E-Mail an Hr Hemm gesendet wurde +# Wenn nicht und es ein Wochentags-Device gibt +# suche das SRC-Device +# rufe das Script was udev auch machen sollte +#set -x +EMAILDONE="$(journalctl -u postfix.service --since "$(date -d '4 hours ago' '+%Y-%m-%d %H:%M')" | grep hemm@lkw-kitzingen.de)" +INUSE="$(lsof | grep /backup/daily.0)" +if [ -z "$EMAILDONE" ] && [ -z "$INUSE" ] ; then + MAPPERDEV=$(ls -1tr /dev/mapper/{Montag,Dienstag,Mittwoch,Donnerstag,Freitag} 2>/dev/null | tail -1) + if [ -n "$MAPPERDEV" ]; then + DAY=${MAPPERDEV##*/} + #echo $MAPPERDEV $DAY + MAJORMINOR=$(/sbin/dmsetup table $MAPPERDEV | awk '{print $7}') + SYS=$(find /sys/dev/ -name $MAJORMINOR) + source $SYS/uevent + #echo $DEVNAME + /lib/udev/mail_hd_stat /dev/$DEVNAME $DAY + fi +fi +