Skip to content

Instantly share code, notes, and snippets.

@viktoschi
Created February 22, 2021 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktoschi/4a164c280be47479672bf88c7f1cf031 to your computer and use it in GitHub Desktop.
Save viktoschi/4a164c280be47479672bf88c7f1cf031 to your computer and use it in GitHub Desktop.
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