Created
February 22, 2021 21:58
-
-
Save viktoschi/4a164c280be47479672bf88c7f1cf031 to your computer and use it in GitHub Desktop.
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
NumToKeep=144 | |
BackupFolderPath=/root/server/valheimbackups/ | |
Worldsavelocation=/root/server/valheim/worlds/ | |
if [[ ! -d $BackupFolderPath ]] | |
then | |
echo "$BackupFolderPath does not exist on your filesystem." | |
mkdir $BackupFolderPath | |
fi | |
Date=$(date +%Y-%m-%d-%H-%M-%S) | |
Sum=$((NumToKeep+1)) | |
tar -czvf $BackupFolderPath$Date.tar.gz $Worldsavelocation | |
ls -dt $BackupFolderPath/* | tail -n +$Sum | xargs rm -rf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment