added backupAll

This commit is contained in:
oliver
2026-04-22 17:59:48 -03:00
parent 7e23c50a4f
commit 2cbb775d7e
6 changed files with 121 additions and 5 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
set -euo pipefail # Fail on error, undefined variables, and pipe errors
# Create backup filename
FILENAME="$(date +"%Y%m%d_%H%M").zip"
BACKUP_DIR="/BACKUP/$UUID"
mkdir -p "$BACKUP_DIR"
tar -czvf "$BACKUP_DIR/$FILENAME" -C "/4server/data" "$UUID"
# Remove old backups beyond the configured slots
ls -t "$BACKUP_DIR"/[0-9]*.zip 2>/dev/null | tail -n +$((BACKUP_SLOTS + 1)) | while read -r file; do
echo "Deleting old backup: $file"
doas rm -f "$file"
done