Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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