Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #=======================================================#
- # ToDo: #
- # - Add a set number on how many backups #
- # should be made. #
- #=======================================================#
- GameType="Sandbox" #Sandbox, Survival, Multiplayer, etc.
- SaveName="07-01-2017_04-52-11" #Make sure you copy the folder name.
- Timeout=20 #Timeout in seconds. The default of 300 (5 minutes) is likely adequate. Even numbers recommended.
- SERVICE=ProjectZomboid64 #Change this to ProjectZomboid32 if you're using 32bit java!
- BackupCount=5 #Amount of backups to be made.
- #===========================================================================================#
- # No need to change anything below. #
- #===========================================================================================#
- GameName="Project Zomboid"
- sleep 1 #Unused in final script
- #steam steam://rungameid/108600
- mkdir -p "$HOME/Zomboid/Saves/Backups/$SaveName"
- i=1
- Wait=$(($Timeout))
- while [ $i -gt -1 ]; do
- while [ $Wait -gt 0 ]; do
- clear && echo -ne "Creating a backup in" $Wait "seconds." && sleep 1
- : $((Wait--))
- done
- if ps ax | grep -v grep | grep $SERVICE > /dev/null
- then
- cp "$HOME/Zomboid/Saves/$GameType/$SaveName/map_p.bin" "$HOME/Zomboid/Saves/Backups/$SaveName/map_p.bin.backup$i"
- #Make $i +1 each time it passes through, until it reaches $BackupCount and resets to 1.
- [ $i = 1 ] && i=2 || i=1
- Wait=$(($Timeout))
- else
- Wait=$((30))
- while [ $Wait -gt 0 ]; do
- clear && printf "$GameName is not detected as running, and no further backups will be made. \n"
- echo -ne "Checking if game is running in" $Wait "seconds." && sleep 1
- : $((Wait--))
- done
- if ps ax | grep -v grep | grep $SERVICE > /dev/null
- then
- Wait=$(($Timeout-30)) && continue
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement