-
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.
feat: Custom backup and save only world (#250)
* feat: Custom backup * fix: Use of new backup system * fix: Remove usage of sudo * fix: Correct scriptDir * fix: Correct deletion * fix: Show log at console * fix: Correct timestamp for backups * fix: Update versions for actions * docs: Update docs
- Loading branch information
Showing
8 changed files
with
94 additions
and
113 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
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
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,16 +1,13 @@ | ||
|
||
# Backups | ||
|
||
The backup command allows the creation of .tar.gz archives of a game server, alter these three settings by editing LinuxGSM Config | ||
The backup command allows the creation of .tar.gz archives of the world of the server, alter these three settings by changing the following environments | ||
|
||
* maxbackups | ||
* maxbackupdays | ||
* stoponbackup | ||
|
||
Backups settings can be changed in */path/to/LGSM-Config/common.cfg* | ||
* BACKUP_HOUR -> Must be 0-23 | ||
* BACKUP_MAX | ||
|
||
If you wants to force a backup run this command: | ||
|
||
```bash | ||
docker-compose exec 7dtdserver ./sdtdserver backup | ||
docker-compose exec 7dtdserver ./scripts/server_backup.sh | ||
``` |
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
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
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,4 +1,4 @@ | ||
#!/bin/bash | ||
echo "0 5 * * * /home/sdtdserver/sdtdserver backup > /dev/null 2>&1" >> crontab.txt | ||
echo "0 $BACKUP_HOUR * * * /home/sdtdserver/scripts/server_backup.sh >> /home/sdtdserver/log/sdtdserver-console.log 2>&1" >> crontab.txt | ||
|
||
echo "[INFO] Activated automatic backup at 5AM" | ||
echo "[INFO] Activated automatic backup at $BACKUP_HOUR" |
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,10 +1,33 @@ | ||
#!/bin/bash | ||
echo "[INFO] Starting backup, this backup will create a complete tar bzip2 archive of the whole server" | ||
|
||
echo "[INFO] Starting backup, this backup will create a backup in a .tar.gz archive of your worlds" | ||
sleep 3s | ||
|
||
./sdtdserver backup | ||
BACKUP_FOLDER="/home/sdtdserver/.local/share/7DaysToDie/" | ||
BACKUP_DESTINATION="/home/sdtdserver/lgsm/backup/" | ||
scriptsDir="/home/sdtdserver/scripts" | ||
|
||
echo "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" | ||
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" | ||
|
||
sleep 3s | ||
|
||
echo "[INFO] Backup complete" | ||
|
||
find "$BACKUP_DESTINATION" -type f -name "*.tar.gz" -mtime +7 -delete |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
scriptsDir="/home/sdtdserver/scripts" | ||
|
||
echo "# Crontab file" > crontab.txt | ||
|
||
if [ "${BACKUP,,}" == 'yes' ]; then | ||
source "$scriptsDir/crontab/backup.sh" | ||
fi | ||
|
||
if [ "${MONITOR,,}" == 'yes' ]; then | ||
source "$scriptsDir/crontab/monitor.sh" | ||
fi | ||
|
||
echo "# Don't remove the empty line at the end of this file. It is required to run the cron job" >> crontab.txt | ||
|
||
# Add crontab | ||
crontab crontab.txt | ||
|
||
# Cleanup junk file | ||
rm crontab.txt |