Initial backup import

This commit is contained in:
Michael Seidel
2026-03-28 18:13:57 +01:00
commit 59bc523e83
78 changed files with 553 additions and 0 deletions

17
etc/fstab Normal file
View File

@@ -0,0 +1,17 @@
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during installation
UUID=9c56b6fd-2a60-4480-b82f-240da2e66acc / ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=C863-7654 /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda3 during installation
UUID=da855cd2-3dc7-490d-a9c9-9c6b473b5e8b none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

7
etc/hosts Normal file
View File

@@ -0,0 +1,7 @@
127.0.0.1 localhost
127.0.1.1 debian
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

15
etc/network/interfaces Normal file
View File

@@ -0,0 +1,15 @@
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens18
iface ens18 inet static
address 192.168.199.5
netmask 255.255.255.0
gateway 192.168.199.170

21
etc/nsswitch.conf Normal file
View File

@@ -0,0 +1,21 @@
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: files systemd sss winbind
group: files systemd sss winbind
shadow: files systemd sss
gshadow: files systemd
hosts: files dns
networks: files
protocols: db files
services: db files sss
ethers: db files
rpc: db files
netgroup: nis sss
automount: sss

55
etc/samba/smb.conf Normal file
View File

@@ -0,0 +1,55 @@
# Global parameters
[global]
kerberos method = secrets and keytab
log file = /var/log/samba/log.%m
logging = file
map to guest = Bad User
max log size = 1000
obey pam restrictions = No
pam password change = Yes
panic action = /usr/share/samba/panic-action %d
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
passwd program = /usr/bin/passwd %u
realm = FOCUS-ON-IT.DE
security = ADS
template shell = /bin/bash
unix password sync = Yes
usershare allow guests = Yes
winbind use default domain = Yes
workgroup = FOCUS-ON-IT
idmap config focus-on-it : range = 20001-999999
idmap config focus-on-it : backend = rid
idmap config * : range = 10000-20000
idmap config * : backend = tdb
[homes]
browseable = No
comment = Home Directories
create mask = 0700
directory mask = 0700
valid users = %S
[printers]
browseable = No
comment = All Printers
create mask = 0700
path = /var/tmp
printable = Yes
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[Nextcloud-Homes]
path = /srv/nextcloud-data/%U
read only = no
browseable = no
create mask = 0700
directory mask = 0700
valid users = %U

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/chrony.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-init-hotplugd.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-config.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-final.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-init-local.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-init-main.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cloud-init-network.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/systemd-timesyncd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/wtmpdb-update-boot.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/getty@.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/grub-common.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/grub-common.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/chrony.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/console-setup.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/cron.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/e2scrub_reap.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/fail2ban.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/grub-common.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/networking.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/nmbd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/oddjobd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/remote-fs.target

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/rsyslog.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/samba-ad-dc.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/smbd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/ssh.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/unattended-upgrades.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/winbind.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs.target

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/networking.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/nmbd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/samba-ad-dc.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/smbd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sshd-keygen.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sshd-keygen.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/ssh.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sshd-keygen.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sshd-keygen.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-autofs.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-nss.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-pac.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-pam.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-ssh.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/sssd-sudo.socket

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/grub-common.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/grub-common.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/apparmor.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/keyboard-setup.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/systemd-pstore.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/systemd-timesyncd.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/rsyslog.service

View File

@@ -0,0 +1 @@
/lib/systemd/system/apt-daily-upgrade.timer

View File

@@ -0,0 +1 @@
/lib/systemd/system/apt-daily.timer

View File

@@ -0,0 +1 @@
/lib/systemd/system/dpkg-db-backup.timer

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/e2scrub_all.timer

View File

@@ -0,0 +1 @@
/lib/systemd/system/fstrim.timer

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/logrotate.timer

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/man-db.timer

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-zed.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-import-cache.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-load-module.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-volume-wait.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-import.target

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-load-module.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-mount.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-share.service

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-volumes.target

View File

@@ -0,0 +1 @@
/usr/lib/systemd/system/zfs-zed.service

5
root/.ssh/config Normal file
View File

@@ -0,0 +1,5 @@
Host gitea
HostName git.focus-on-it.net
User git
Port 2222
IdentityFile /root/.ssh/id_ed25519

View File

@@ -0,0 +1,267 @@
#!/usr/bin/env bash
set -Eeuo pipefail
########################################
# Einstellungen
########################################
SOURCE_LIST="/root/backup-config/sources.txt"
BACKUP_ROOT="/root/backup-config/backup"
LOGFILE="/var/log/backup-config.log"
# Git
USE_GIT="yes"
GIT_BRANCH="DockerDMZ_Configfiles"
# Verzeichnisse, die automatisch nach Config-Dateien durchsucht werden
AUTO_SCAN_DIRS=(
"/root/docker"
)
# Dateitypen, die automatisch erkannt werden
AUTO_FILE_TYPES=(
"*.sh"
"*.yml"
"*.yaml"
"*.env"
"*.conf"
"*.cnf"
"*.ini"
"*.json"
"*.toml"
"*.service"
"Dockerfile"
"docker-compose.yml"
"compose.yml"
)
# Pfade, die beim automatischen Scan ausgeschlossen werden
EXCLUDES=(
"*/data/pages/*"
"*/data/media/*"
"*/data/cache/*"
"*/data/tmp/*"
"*/logs/*"
"*/log/*"
"*/db/*"
"*/database/*"
"*/mysql/*"
"*/mariadb/*"
"*/postgres/*"
"*/redis/*"
"*/.git/*"
)
########################################
# Logging
########################################
log() {
printf '%s %s\n' "$(date '+%F %T')" "$1" | tee -a "$LOGFILE"
}
########################################
# Hilfsfunktionen
########################################
is_excluded() {
local path="$1"
local ex
for ex in "${EXCLUDES[@]}"; do
if [[ "$path" == $ex ]]; then
return 0
fi
done
return 1
}
copy_path() {
local src="$1"
local rel
local dst
if is_excluded "$src"; then
log "SKIP (exclude): $src"
return 0
fi
if [[ -f "$src" ]]; then
rel="${src#/}"
dst="$BACKUP_ROOT/$rel"
mkdir -p "$(dirname "$dst")"
cp -a "$src" "$dst"
log "OK (FILE): $src -> $dst"
return 0
fi
if [[ -d "$src" ]]; then
rel="${src#/}"
dst="$BACKUP_ROOT/$rel"
mkdir -p "$(dirname "$dst")"
cp -a "$src" "$dst"
log "OK (DIR): $src -> $dst"
return 0
fi
log "WARN: Pfad nicht gefunden: $src"
return 1
}
########################################
# Automatischer Scan
########################################
auto_scan() {
local dir
local file
local find_expr=()
log "INFO: Starte automatischen Scan"
# find-Ausdruck für Dateitypen bauen
for pattern in "${AUTO_FILE_TYPES[@]}"; do
find_expr+=( -name "$pattern" -o )
done
unset 'find_expr[${#find_expr[@]}-1]'
for dir in "${AUTO_SCAN_DIRS[@]}"; do
if [[ ! -d "$dir" ]]; then
log "WARN: Auto-Scan-Verzeichnis fehlt: $dir"
continue
fi
while IFS= read -r file; do
if is_excluded "$file"; then
log "SKIP (exclude): $file"
continue
fi
copy_path "$file" || true
done < <(
find "$dir" -type f \( "${find_expr[@]}" \) 2>/dev/null | sort -u
)
done
}
########################################
# Git
########################################
git_prepare_repo() {
if [[ "$USE_GIT" != "yes" ]]; then
return 0
fi
if ! command -v git >/dev/null 2>&1; then
log "ERROR: Git ist nicht installiert"
return 1
fi
mkdir -p "$BACKUP_ROOT"
if [[ ! -d "$BACKUP_ROOT/.git" ]]; then
log "INFO: Git-Repository wird initialisiert"
git -C "$BACKUP_ROOT" init
fi
# Benutzerinfo prüfen
if ! git -C "$BACKUP_ROOT" config user.name >/dev/null; then
log "WARN: Git user.name ist im Repository nicht gesetzt"
fi
if ! git -C "$BACKUP_ROOT" config user.email >/dev/null; then
log "WARN: Git user.email ist im Repository nicht gesetzt"
fi
}
git_checkout_branch() {
local branch="$1"
if [[ "$USE_GIT" != "yes" ]]; then
return 0
fi
if [[ -z "$branch" ]]; then
return 0
fi
if git -C "$BACKUP_ROOT" show-ref --verify --quiet "refs/heads/$branch"; then
git -C "$BACKUP_ROOT" checkout "$branch" >/dev/null 2>&1
log "INFO: Git-Branch aktiviert: $branch"
return 0
fi
# Wenn noch gar kein Commit existiert, zuerst initialen Commit anlegen
if ! git -C "$BACKUP_ROOT" rev-parse --verify HEAD >/dev/null 2>&1; then
git -C "$BACKUP_ROOT" add -A
if ! git -C "$BACKUP_ROOT" diff --cached --quiet; then
git -C "$BACKUP_ROOT" commit -m "Initial backup import"
log "INFO: Initialer Commit erstellt"
fi
fi
git -C "$BACKUP_ROOT" checkout -b "$branch" >/dev/null 2>&1
log "INFO: Git-Branch erstellt und aktiviert: $branch"
}
git_commit_changes() {
local changed_files
local commit_msg
if [[ "$USE_GIT" != "yes" ]]; then
return 0
fi
git -C "$BACKUP_ROOT" add -A
if git -C "$BACKUP_ROOT" diff --cached --quiet; then
log "INFO: Keine Änderungen für Git"
return 0
fi
changed_files="$(git -C "$BACKUP_ROOT" diff --cached --name-only | sed 's#^# - #' || true)"
commit_msg=$(
cat <<EOF
Config-Backup $(date '+%F %T')
Geänderte Dateien:
$changed_files
EOF
)
git -C "$BACKUP_ROOT" commit -m "$commit_msg"
log "OK: Git-Commit erstellt"
}
########################################
# Hauptlogik
########################################
main() {
mkdir -p "$BACKUP_ROOT"
if [[ -f "$SOURCE_LIST" ]]; then
log "INFO: Lese Source-Liste: $SOURCE_LIST"
while IFS= read -r line || [[ -n "$line" ]]; do
[[ -z "${line// }" ]] && continue
[[ "$line" =~ ^[[:space:]]*# ]] && continue
copy_path "$line" || true
done < "$SOURCE_LIST"
else
log "WARN: Source-Liste fehlt: $SOURCE_LIST"
fi
auto_scan
git_prepare_repo
git_checkout_branch "$GIT_BRANCH"
git_commit_changes
log "INFO: Lauf abgeschlossen"
}
main

View File

@@ -0,0 +1,86 @@
#!/usr/bin/env bash
set -Eeuo pipefail
BASE_DIR="/root/backup-config"
BACKUP_DIR="$BASE_DIR/backup"
BACKUP_SCRIPT="$BASE_DIR/backup-config.sh"
LOGFILE="/var/log/backup-config-run.log"
BRANCH="DockerDMZ_Configfiles"
log() {
printf '%s %s\n' "$(date '+%F %T')" "$1" | tee -a "$LOGFILE"
}
main() {
if [[ ! -x "$BACKUP_SCRIPT" ]]; then
echo "Backup-Skript nicht gefunden oder nicht ausführbar: $BACKUP_SCRIPT" >&2
exit 1
fi
mkdir -p "$BACKUP_DIR"
log "INFO: Starte Backup"
"$BACKUP_SCRIPT"
log "INFO: Backup beendet"
cd "$BACKUP_DIR"
if ! command -v git >/dev/null 2>&1; then
log "ERROR: Git ist nicht installiert"
exit 1
fi
if [[ ! -d .git ]]; then
log "INFO: Git-Repository wird initialisiert"
git init
fi
# Branch aktivieren oder anlegen
if git show-ref --verify --quiet "refs/heads/$BRANCH"; then
git checkout "$BRANCH" >/dev/null 2>&1
log "INFO: Git-Branch aktiviert: $BRANCH"
else
if git rev-parse --verify HEAD >/dev/null 2>&1; then
git checkout -b "$BRANCH" >/dev/null 2>&1
else
git checkout --orphan "$BRANCH" >/dev/null 2>&1
fi
log "INFO: Git-Branch erstellt: $BRANCH"
fi
git add -A
if git diff --cached --quiet; then
log "INFO: Keine neuen Dateiinhalte für Commit"
else
git commit -m "Config-Backup $(hostname) $(date '+%F %T')"
log "INFO: Commit erstellt"
fi
if ! git remote get-url origin >/dev/null 2>&1; then
log "WARN: Kein Remote 'origin' konfiguriert, Push übersprungen"
exit 0
fi
# Remote-Infos aktualisieren
git fetch origin "$BRANCH" >/dev/null 2>&1 || true
# Falls der Remote-Branch noch nicht existiert
if ! git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
git push -u origin "$BRANCH"
log "INFO: Initialer Push des Branches erfolgreich"
exit 0
fi
# Prüfen, ob lokale Commits noch nicht gepusht wurden
AHEAD_COUNT="$(git rev-list --count "origin/$BRANCH..$BRANCH" 2>/dev/null || echo 0)"
if [[ "$AHEAD_COUNT" -gt 0 ]]; then
git push origin "$BRANCH"
log "INFO: Push erfolgreich ($AHEAD_COUNT lokale Commits übertragen)"
else
log "INFO: Kein Push nötig, Remote ist aktuell"
fi
}
main

View File

@@ -0,0 +1,11 @@
#systembasis
/etc/network/interfaces
/etc/hosts
/etc/fstab
/etc/samba/smb.conf
/etc/systemd/system
/root/backup-config/backup-config.sh
/root/backup-config/run-backup-and-push.sh
/root/backup-config/sources.txt
/root/.ssh/config
/etc/nsswitch.conf