#!/bin/bash # MSP360 Backup - Configure only (MSP360 already installed) # Usage: bash msp360-setup.sh # Credentials: fetched from Gitea (/etc/msp360-gitea-token) or local msp360.conf set -e SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" CONF="$SCRIPT_DIR/msp360.conf" TOKEN_FILE="/etc/msp360-gitea-token" GITEA_RAW="https://gitea.orbishosting.com/myron/msp360-config/raw/branch/main/msp360.conf" CBB="/opt/local/MSP360 Backup/bin/cbbCommandLine" if [ -f "$CONF" ]; then source "$CONF" elif [ -f "$TOKEN_FILE" ]; then GITEA_TOKEN=$(cat "$TOKEN_FILE") curl -sf -H "Authorization: token $GITEA_TOKEN" "$GITEA_RAW" -o /tmp/msp360.conf source /tmp/msp360.conf rm -f /tmp/msp360.conf else echo "ERROR: No msp360.conf and no /etc/msp360-gitea-token" exit 1 fi PLAN_NAME="${1:-${PLAN_NAME:-MyHost-Backup}}" FULL_TIME="${2:-${FULL_TIME:-01:00}}" INC_TIME="${3:-${INC_TIME:-02:00}}" BACKUP_PATH="${MOUNT_POINT:-/mnt/nas-backups}/${BACKUP_SUBDIR:-MSPBackups}" "$CBB" activateLicense -e "$LICENSE_EMAIL" -free apt-get install -y cifs-utils 2>/dev/null | tail -1 mkdir -p "${MOUNT_POINT}" /etc/nas-creds [ -f /etc/nas-creds/msp360 ] || \ printf "username=%s\npassword=%s\n" "$NAS_USER" "$NAS_PASS" > /etc/nas-creds/msp360 chmod 600 /etc/nas-creds/msp360 mountpoint -q "${MOUNT_POINT}" || \ mount -t cifs "//${NAS_HOST}/${NAS_SHARE}" "${MOUNT_POINT}" \ -o credentials=/etc/nas-creds/msp360,uid=0,gid=0,noperm,_netdev mkdir -p "$BACKUP_PATH" grep -q "${MOUNT_POINT}" /etc/fstab || \ echo "//${NAS_HOST}/${NAS_SHARE} ${MOUNT_POINT} cifs credentials=/etc/nas-creds/msp360,uid=0,gid=0,noperm,_netdev 0 0" >> /etc/fstab "$CBB" addAccount -st FileSystem -d "NAS-MSPBackups" -c "$BACKUP_PATH" 2>&1 "$CBB" addBackupPlan \ -n "$PLAN_NAME" \ -a "NAS-MSPBackups" \ -f "/" \ -ef "/proc" -ef "/sys" -ef "/dev" -ef "/run" -ef "/tmp" -ef "/mnt" \ -es no \ -purge 1m -purgeBy backupDate -keepLastVersion yes \ -runMissed yes \ -en yes -every day -at "$INC_TIME" \ -enFull yes -everyFull week -atFull "$FULL_TIME" -weekdayFull "su" 2>&1 echo "Done. Plans:" "$CBB" plan -l