Skip to content

Commit

Permalink
fix: Correct backup remove and better info messages (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinanrra authored Jul 3, 2024
1 parent d5816a2 commit 35e7994
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions scripts/server_backup.sh
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
#!/bin/bash
echo "[INFO] Starting backup, this backup will create a backup in a .tar.gz archive of your worlds"
echo "[BACKUP] Starting backup, this backup will create a backup in a .tar.gz archive of your worlds"
sleep 3s

BACKUP_FOLDER="/home/sdtdserver/.local/share/7DaysToDie/"
BACKUP_DESTINATION="/home/sdtdserver/lgsm/backup/"
scriptsDir="/home/sdtdserver/scripts"

echo "Stopping 7 Days To Die"
echo "[BACKUP] Stopping 7 Days To Die"
./sdtdserver stop

# Disable crontab and montoring if enabled
crontab -r

# Backup the specified folder
echo "Backing up folder: $BACKUP_FOLDER"
echo "[BACKUP] Backing up folder: $BACKUP_FOLDER"
TIMESTAMP=$(date +"%Y-%m-%d-%H%M%S")
BACKUP_FILE="$BACKUP_DESTINATION/sdtdserver-$TIMESTAMP.tar.gz"
tar -czvf $BACKUP_FILE $BACKUP_FOLDER

# Enable crontab and monitoring
source "$scriptsDir/utils/crontab.sh"

echo "Starting 7 Days To Die"
./sdtdserver start

echo "Backup completed. Backup file: $BACKUP_FILE"
echo "[BACKUP] Backup completed. Backup file: $BACKUP_FILE"

sleep 3s

echo "[INFO] Backup complete"
echo "[BACKUP] Backup complete"

find "$BACKUP_DESTINATION" -type f -name "*.tar.gz" -mtime +7 -delete
echo "[BACKUP] Removeing backups older than $BACKUP_MAX days"
find "$BACKUP_DESTINATION" -type f -name "*.tar.gz" -mtime +$BACKUP_MAX -delete

echo "[BACKUP] Starting 7 Days To Die"
./sdtdserver start

0 comments on commit 35e7994

Please sign in to comment.