Archive for Januar, 2021
Dienstag, Januar 26th, 2021
#!/bin/bash
####################################
# /usr/local/bin/createSnapshotHourly.sh
#
# Erstellt ein Snapshot mit Hilfe von XFS Reflink
####################################
umask 022
PATH=/bin:/usr/bin
export PATH
# Quellverzeichnis des Backups
backupVerzeichnis=~/Schreibtisch
# Zielverzeichnis des Backups
snapshotVerzeichnis=~/.Snapshots
# Ist genügend freier Speicherplatz (> 25 GB) vorhanden
if [ -d „${snapshotVerzeichnis}“ ];
then
FreierSpeicherplatz=0;
else
/usr/bin/mkdir -p ${snapshotVerzeichnis};
/usr/bin/chattr -R +d ${snapshotVerzeichnis}/;
/usr/bin/sync;
FreierSpeicherplatz=0;
fi;
FreierSpeicherplatz=`/usr/bin/df -h ${snapshotVerzeichnis} | tail -n1 | /usr/bin/awk ‚{print $4}‘ | grep -i „G“ | sed ’s/.$//’`
if [ ${FreierSpeicherplatz} -ge 25 ];
then
# Kontrolle, ob das Quellverzeichnis existiert
if [ -d „${backupVerzeichnis}“ ];
then
# Temporä¤res Verzeichnis löschen
if [ -d „${snapshotVerzeichnis}/hourly.tmp“ ];
then
/usr/bin/rm -Rf ${snapshotVerzeichnis}/hourly.tmp;
/usr/bin/sync;
fi;
# Neuer Snapshot erstellen
if [ -d „${snapshotVerzeichnis}/hourly.tmp“ ];
then
echo „Zielverzeichnis des Backups konnte nicht gelöscht werden!“;
exit 3;
else
# Snapshot mit Hilfe von XFS Reflink erstellen
/usr/bin/cp -R –no-dereference –preserve –one-file-system –reflink=always ${backupVerzeichnis}/ ${snapshotVerzeichnis}/hourly.tmp/;
/usr/bin/sync;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.tmp“ ];
then
/usr/bin/touch -m ${snapshotVerzeichnis}/hourly.tmp/;
/usr/bin/sync;
else
echo „Zielverzeichnis des Backups konnte nicht erstellt werden!“;
exit 4;
fi;
# Snapshots rotieren
if [ -d „${snapshotVerzeichnis}/hourly.8“ ];
then
/usr/bin/rm -Rf ${snapshotVerzeichnis}/hourly.8;
/usr/bin/sync;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.7“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.7 ${snapshotVerzeichnis}/hourly.8;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.6“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.6 ${snapshotVerzeichnis}/hourly.7;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.5“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.5 ${snapshotVerzeichnis}/hourly.6;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.4“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.4 ${snapshotVerzeichnis}/hourly.5;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.3“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.3 ${snapshotVerzeichnis}/hourly.4;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.2“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.2 ${snapshotVerzeichnis}/hourly.3;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.1“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.1 ${snapshotVerzeichnis}/hourly.2;
fi;
if [ -d „${snapshotVerzeichnis}/hourly.0“ ];
then
/usr/bin/mv ${snapshotVerzeichnis}/hourly.0 ${snapshotVerzeichnis}/hourly.1;
fi;
# Neuer Snapshot veröffentlichen
/usr/bin/mv ${snapshotVerzeichnis}/hourly.tmp ${snapshotVerzeichnis}/hourly.0;
/usr/bin/sync;
else
echo „Quellverzeichnis des Backups existiert nicht!“;
exit 2;
fi;
else
echo „Nicht genügend freier Speicherplatz!“;
exit 1;
fi;
exit 0
Posted in Administration, Raspberry Pi | No Comments »
Dienstag, Januar 26th, 2021
Bei allen Unternehmen die per Verordnung für volkswirtschaftlich bedeutsam erklärt würden könnte der Staat künftig vorschreiben mit welchen Sicherheitsvorkehrungen Cyberangriffe abgewehrt werden müssen. Das Bundesamt für Sicherheit in der Informationstechnik (BSI) soll zur Aufsichtsbehörde aufgewertet werden
Posted in Administration | No Comments »