Files
nextcloudRemoteBackupScripts/NextcloudBackupScript.sh
T
2026-04-07 09:40:22 +02:00

51 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
source TalkLib.sh
# --- KONFIGURATION ---
# Pfad zum lokalen Verzeichnis (Wichtig: Schrägstrich am Ende!)
SOURCE_DIR="/mnt/data/"
# Remote-Zugangsdaten
REMOTE_USER="backupuser"
REMOTE_HOST="alsdorf.spznord.de"
REMOTE_PORT="1022" # Neuer Port für die Übertragung
REMOTE_DIR="/mnt/disk0/backups/nextcloud/data/"
#nextcloud-Zugangsdaten
NC_URL="https://cloud.ptv-euregio.de"
NC_USER="MittagsApp"
NC_APP_PASSWORD="inter2563*"
ROOM_TOKEN="b4gs3g9z"
NEWLINE=$'\n'
Mesg="*** Nextcloud Data Backup ***${NEWLINE}"
# --- LOGIK ---
echo "Starte Synchronisation von $SOURCE_DIR nach $REMOTE_HOST auf Port $REMOTE_PORT..."
# Pfad zum SSH-Key
SSH_KEY="/home/DEIN_USER/.ssh/id_ed25519"
# rsync mit Ausschlussfiltern:
# --exclude 'DATEINAME': Verhindert, dass diese Datei kopiert wird
rsync -avzh \
-e "ssh -p $REMOTE_PORT -i $SSH_KEY" \
--exclude 'nextcloud.log' \
--exclude 'nextcloud.log.1' \
--exclude 'audit.log' \
--exclude 'audit.log.1' \
--exclude 'updater.log' \
--exclude 'updater.log.1' \
--exclude 'flow.log' \
--exclude 'flow.log.1' \
--exclude 'appdata_ocubwyrxncdg' \
--progress \
"$SOURCE_DIR" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR"
# Status prüfen
if [ $? -eq 0 ]; then
Mesg="${Mesg}Nextcloud Data rsync Ok."
else
Mesg="${Mesg}Nextcloud Data rsync failed."
fi
sendMessage2Room $NC_URL $NC_USER $NC_APP_PASSWORD $ROOM_TOKEN "$Mesg"