jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
898 stars 152 forks source link

[Feature Request] Backup retention time #138

Closed OliveiraNt closed 5 months ago

OliveiraNt commented 5 months ago

Have you read the Important information text above

Describe the feature

I think it would be a useful to put an option to remove old backups to avoid disk space waste.

I currently use something like this on my server:

0 0 * * * find ${BACKUP_DIR} -type f -mtime +${DAYS_TO_RETAIN} -exec rm {} \;

It could other cron or be added to backupmanager.sh to run after.

Something like:

#!/bin/bash

DATE=$(date +%Y%m%d_%H%M%S)
TIME=$(date +%H-%M-%S)

echo ">>> Creating backup"
echo "> Sending message to gameserver"
cd ~/steamcmd/
rconcli "broadcast $TIME-Backup_in_progress"
sleep 1
rconcli 'broadcast Saving...'
rconcli 'save'
rconcli 'broadcast Done...'
sleep 15
# Create backup dir and change into it
mkdir -p /palworld/backups && cd /palworld/Pal
tar cfz /palworld/backups/saved-$DATE.tar.gz Saved/
echo ">>> Done"
if [[ -n $DAYS_TO_RETAIN ]] && [[ ! $DAYS_TO_RETAIN -eq 0 ]]; then #Avoid removing all files if defined as 0
    echo ">>> Removing old backups"
    find  /palworld/backups -type f -mtime +${DAYS_TO_RETAIN} -exec rm {} \;
    echo ">>> Done"
fi

Additional information

Final checks

jammsen commented 5 months ago

Hey @OliveiraNt Im working on this right now but dont want to use date for this. More like combination of sorts.

The solution will be like "keep the last X backups" sort of way.

jammsen commented 5 months ago

See also here https://github.com/jammsen/docker-palworld-dedicated-server/issues/27#issuecomment-1910988596

jammsen commented 5 months ago

This was just fixed - See https://github.com/jammsen/docker-palworld-dedicated-server/issues/27#issuecomment-1916979966

Im closing this issue as resolved, feel free to try it out and reopen again if needed.

If you like this project, please consider giving this repo and the docker-hub-repo a Star.