-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correct backup remove and better info messages (#251)
- Loading branch information
Showing
1 changed file
with
10 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |