Last active
January 22, 2025 13:04
-
-
Save danilogco/7d1a1ddecc70e1fb63ae179738373704 to your computer and use it in GitHub Desktop.
Palworld dedicated server backup script - Ubuntu Server
This file contains hidden or 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
# crontab -e | |
# 0 3 * * * /home/steam/backup.sh | |
# 30 3 * * * /home/steam/clean.sh | |
# 0 4 * * * /sbin/shutdown -r now | |
#!/bin/bash | |
# Caminho para o diretório de saves do Palworld | |
SAVE_DIR="/home/steam/.steam/steam/steamapps/common/PalServer/Pal/Saved" | |
# Nome do bucket S3 | |
BUCKET_NAME="palworld-saves-backup" | |
# Data e hora para nomear o arquivo | |
DATE=$(date +"%Y-%m-%d_%H-%M-%S") | |
# Nome do arquivo de backup | |
BACKUP_FILE="palworld_saves_$DATE.tar.gz" | |
# Criar o arquivo de backup | |
tar -czvf $BACKUP_FILE -C $SAVE_DIR . | |
# Enviar para o S3 | |
aws s3 cp $BACKUP_FILE s3://$BUCKET_NAME/backups/ | |
# Remover o arquivo local após o upload | |
rm $BACKUP_FILE | |
# Listar os backups no S3, ordenar pela data e manter somente os 10 mais recentes | |
BACKUPS=$(aws s3 ls s3://$BUCKET_NAME/backups/ --recursive | sort | head -n -10 | awk '{print $4}') | |
# Excluir os backups antigos | |
for FILE in $BACKUPS; do | |
if [ -n "$FILE" ]; then | |
aws s3 rm s3://$BUCKET_NAME/$FILE | |
fi | |
done | |
echo "Backup concluído e antigos backups excluídos com sucesso." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment