mirror of
https://github.com/myronblair/proxmox-config
synced 2026-06-30 15:59:57 -05:00
d45f88b604
- vm-configs/fstab/: fstab snapshots for JARVIS, NPM, NovaCPX, Jellyfin, MediaStack - vm-configs/network-reference.md: full IP/service/NAS/WireGuard reference - wireguard/: MediaStack wg0/wg1 and WireGuard CT nord0/wg-clients configs - msp360/: install and setup scripts + staggered backup schedule Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01X8tDRrQqgLjqXebMCBNcP3
85 lines
2.8 KiB
Bash
85 lines
2.8 KiB
Bash
#!/bin/bash
|
|
# MSP360 Backup - Complete Linux Install & Configure
|
|
# Run as root from the directory containing this script and the .deb file.
|
|
#
|
|
# Credentials are fetched from private Gitea repo (myron/msp360-config).
|
|
# Requires /etc/msp360-gitea-token on the target machine.
|
|
# OR place a filled-in msp360.conf in the same directory as this script.
|
|
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
|
|
echo "Using local msp360.conf"
|
|
source "$CONF"
|
|
elif [ -f "$TOKEN_FILE" ]; then
|
|
echo "Fetching config from Gitea..."
|
|
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 found and no /etc/msp360-gitea-token present."
|
|
echo " Option A: Place a filled-in msp360.conf in $SCRIPT_DIR"
|
|
echo " Option B: Put your Gitea token in /etc/msp360-gitea-token (chmod 600)"
|
|
exit 1
|
|
fi
|
|
|
|
BACKUP_PATH="${MOUNT_POINT}/${BACKUP_SUBDIR}"
|
|
CBB_DEB=$(ls "$SCRIPT_DIR"/ubuntu14_MSP360_*.deb 2>/dev/null | head -1)
|
|
|
|
echo "=== Step 1: Install MSP360 ==="
|
|
if [ -f "$CBB_DEB" ]; then
|
|
dpkg -i "$CBB_DEB"
|
|
sleep 5
|
|
else
|
|
echo "WARNING: No .deb found — assuming already installed"
|
|
fi
|
|
|
|
echo "=== Step 2: Activate license ==="
|
|
"$CBB" activateLicense -e "$LICENSE_EMAIL" -free
|
|
|
|
echo "=== Step 3: Install cifs-utils ==="
|
|
apt-get install -y cifs-utils
|
|
|
|
echo "=== Step 4: Mount NAS ==="
|
|
mkdir -p "$MOUNT_POINT" /etc/nas-creds
|
|
printf "username=%s\npassword=%s\n" "$NAS_USER" "$NAS_PASS" > /etc/nas-creds/msp360
|
|
chmod 600 /etc/nas-creds/msp360
|
|
|
|
if ! mountpoint -q "$MOUNT_POINT"; then
|
|
mount -t cifs "//${NAS_HOST}/${NAS_SHARE}" "$MOUNT_POINT" \
|
|
-o credentials=/etc/nas-creds/msp360,uid=0,gid=0,noperm,_netdev
|
|
fi
|
|
df -h "$MOUNT_POINT"
|
|
|
|
echo "=== Step 5: Create backup directory ==="
|
|
mkdir -p "$BACKUP_PATH"
|
|
|
|
echo "=== Step 6: Add fstab entry ==="
|
|
FSTAB_LINE="//${NAS_HOST}/${NAS_SHARE} ${MOUNT_POINT} cifs credentials=/etc/nas-creds/msp360,uid=0,gid=0,noperm,_netdev 0 0"
|
|
grep -q "$MOUNT_POINT" /etc/fstab || echo "$FSTAB_LINE" >> /etc/fstab
|
|
|
|
echo "=== Step 7: Register storage account ==="
|
|
"$CBB" addAccount -st FileSystem -d "NAS-MSPBackups" -c "$BACKUP_PATH"
|
|
|
|
echo "=== Step 8: Create backup plan ==="
|
|
"$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"
|
|
|
|
echo ""
|
|
echo "=== Done! Plan list: ==="
|
|
"$CBB" plan -l
|