Advertisement
Guest User

Project Zomboid Save Backup Utility

a guest
Jan 24th, 2022
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 6.54 KB | None | 0 0
  1. @echo off
  2.  
  3. set savedir=C:\Users\%USERNAME%\Zomboid\Saves
  4.  
  5. set software=Winrar
  6.  
  7. :Main
  8. set compresserror=0
  9. set selecterror=0
  10. set mode=null
  11. cls
  12. echo ===[Project Zomboid Save Backup Utility]===
  13. echo.
  14. echo Welcome to the Project Zomboid Save Backup Utility!
  15. echo       Created by Mr. Nekuromu
  16. echo           V0.1-(1/24/2022)
  17. echo.
  18. echo.
  19. echo    1) Backup Apocalypse Save Data
  20. echo    2) Backup Multiplayer Save Data
  21. echo    3) Backup Survivor Save Data
  22. echo    4) Restore Apocalypse Save Data
  23. echo    5) Restore Multiplayer Save Data
  24. echo    6) Restore Survivor Save Data
  25. echo    7) Exit
  26. echo.
  27. echo    8) Toggle Compression Software
  28. echo.
  29. echo    Compression Software mode: %software%
  30. echo.
  31. set /P c=Select Mode:
  32. if /I "%c%" EQU "1" set mode=Apocalypse& goto FindDir
  33. if /I "%c%" EQU "2" set mode=Multiplayer& goto FindDir
  34. if /I "%c%" EQU "3" set mode=Survivor& goto FindDir
  35. if /I "%c%" EQU "4" set mode=Apocalypse& goto Restore
  36. if /I "%c%" EQU "5" set mode=Multiplayer& goto Restore
  37. if /I "%c%" EQU "6" set mode=Survivor& goto Restore
  38. if /I "%c%" EQU "7" goto Exit
  39. if /I "%c%" EQU "8" goto ToggleSoftware
  40. goto Main
  41.  
  42. :ToggleSoftware
  43. if %software%==Winrar (set software=7-Zip) else set software=Winrar
  44. goto Main
  45.  
  46. :FindDir
  47. cls
  48. echo ===[Project Zomboid Save Backup Utility]===
  49. echo.
  50. echo.
  51. echo.
  52. echo Finding Save Directory...
  53. cd "%savedir%"
  54. echo.
  55. timeout 4
  56.  
  57. :PickSave
  58. cls
  59. echo ===[Project Zomboid Save Backup Utility]===
  60. echo.
  61. echo.
  62. echo.
  63. echo Getting Saves List...
  64. cd "%savedir%\%mode%"
  65. timeout 4
  66. cls
  67. echo ===[Project Zomboid Save Backup Utility]===
  68. echo.
  69. echo Highlight the desired %mode% Save, then [CTRL+C] it.
  70. echo =================================================
  71. dir /b /a:d | findstr /v /i "\_player$"
  72. echo.
  73. set /P sselected=Which to backup?[CTRL+V Here]:
  74. cls
  75. echo ===[Project Zomboid Mod Updater]===
  76. echo.
  77. echo.
  78. echo.
  79. echo Selected %sselected%...
  80. IF %ERRORLEVEL% NEQ 0 (echo. &echo An Error Occured with selection... [ErrorLevel:%ERRORLEVEL%] &set selecterror=1)
  81. if %selecterror%==1 pause
  82. if %selecterror%==1 goto Main
  83. timeout 4
  84.  
  85. :Backup
  86. cls
  87. echo ===[Project Zomboid Save Backup Utility]===
  88. echo.
  89. echo.
  90. echo.
  91. For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%a_%%b_%%c)
  92. For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a-%%b)
  93. set date_and_time=%mydate%_@_%mytime%
  94. set backupfoldername=%sselected%_%date_and_time%
  95. mkdir "%savedir%\_backups\%mode%\%backupfoldername%"
  96. echo Copying Save...
  97. echo.
  98. timeout 4
  99. xcopy /e /v /i "%savedir%\%mode%\%sselected%" "%savedir%\_backups\%mode%\%backupfoldername%\%sselected%"
  100. if %mode%==Multiplayer xcopy /e /v /i "%savedir%\%mode%\%sselected%_player" "%savedir%\_backups\%mode%\%backupfoldername%\%sselected%_player"
  101. cls
  102. echo ===[Project Zomboid Save Backup Utility]===
  103. echo.
  104. echo.
  105. echo.
  106. echo Backup created. "%backupfoldername%"
  107. echo.
  108. timeout 4
  109.  
  110. :CheckSoftware
  111. if %software%==Winrar (goto Winrarcompress) else goto 7Zipcompress
  112.  
  113. :7Zipcompress
  114. set path="C:\Program Files\7-Zip";%path%
  115. cls
  116. echo ===[Project Zomboid Save Backup Utility]===
  117. echo.
  118. echo.
  119. echo.
  120. echo Compressing Backup Save Data...        (This can take a while depending on the save size)
  121. 7z a -t7z -mx9 -r "%savedir%\_backups\%mode%\%backupfoldername%.7z" "%savedir%\_backups\%mode%\%backupfoldername%\*"
  122. IF %ERRORLEVEL% NEQ 0 (echo. &echo An Error Occured with Compression... [ErrorLevel:%ERRORLEVEL%] &set compresserror=1)
  123. if %compresserror%==1 pause & goto CompressErrorChoice
  124. goto DeleteUncompressed
  125.  
  126. :Winrarcompress
  127. set path="C:\Program Files\WinRAR\";%path%
  128. cls
  129. echo ===[Project Zomboid Save Backup Utility]===
  130. echo.
  131. echo.
  132. echo.
  133. echo Compressing Backup Save Data...        (This can take a while depending on the save size)
  134. winrar.exe a -afrar -m5 -ep1 -r -ibck "%savedir%\_backups\%mode%\%backupfoldername%.rar" "%savedir%\_backups\%mode%\%backupfoldername%\*"
  135. IF %ERRORLEVEL% NEQ 0 (echo. &echo An Error Occured with Compression... [ErrorLevel:%ERRORLEVEL%] &set compresserror=1)
  136. if %compresserror%==1 pause & goto CompressErrorChoice
  137.  
  138. :DeleteUncompressed
  139. cls
  140. echo ===[Project Zomboid Save Backup Utility]===
  141. echo.
  142. echo.
  143. echo.
  144. echo Deleting Uncompressed Save Data...
  145. RMDIR /S /Q "%savedir%\_backups\%mode%\%backupfoldername%"
  146. echo.
  147. timeout 4
  148.  
  149. :Backup_Complete
  150. cls
  151. echo ===[Project Zomboid Save Backup Utility]===
  152. echo.
  153. echo.
  154. echo.
  155. echo Backup, and Compression complete. Returning to Main Menu...
  156. echo.
  157. timeout 4
  158. goto Main
  159.  
  160. :Restore
  161. cls
  162. echo ===[Project Zomboid Save Backup Utility]===
  163. echo.
  164. echo.
  165. echo.
  166. echo Getting Save Backups List...
  167. cd "%savedir%\_backups\%mode%"
  168. timeout 4
  169. cls
  170. echo ===[Project Zomboid Save Backup Utility]===
  171. echo.
  172. echo Highlight the desired %mode% backup, then [CTRL+C] it.
  173. echo =================================================
  174. dir /b | find /V ".rar"
  175. dir /b | find /V ".7z"
  176. echo.
  177. set /P bselected=Which to restore?[CTRL+V Here]:
  178. if %software%==Winrar set path="C:\Program Files\WinRAR\";%path%
  179. if %software%==7-Zip set path="C:\Program Files\7-Zip";%path%
  180. cls
  181. echo ===[Project Zomboid Save Backup Utility]===
  182. echo.
  183. echo.
  184. echo.
  185. echo Restoring %bselected%...        (This can take a while depending on the save size)
  186. if %software%==Winrar winrar.exe x -afrar -ibck "%bselected%" *.* "%savedir%\_restore_temp_%bselected%\"
  187. if %software%==7-Zip 7z e -t7z "%bselected%" *.* "%savedir%\_restore_temp_%bselected%\"
  188. IF %ERRORLEVEL% NEQ 0 (echo. &echo An Error Occured with Restoration... [ErrorLevel:%ERRORLEVEL%] &set compresserror=1)
  189. if %compresserror%==1 pause & goto RestoreErrorChoice
  190. xcopy /e /v /i "%savedir%\_restore_temp_%bselected%\*.*" "%savedir%\%mode%"
  191. timeout 4
  192.  
  193. :DeleteRestored
  194. cls
  195. echo ===[Project Zomboid Save Backup Utility]===
  196. echo.
  197. echo.
  198. echo.
  199. echo Cleaning up temp restoration files...
  200. RMDIR /S /Q "%savedir%\_restore_temp_%bselected%"
  201. timeout 4
  202. goto Main
  203.  
  204. :Exit
  205. cls
  206. echo ===[Project Zomboid Save Backup Utility]===
  207. echo.
  208. echo.
  209. echo.
  210. echo Thanks for using Project Zomboid Save Backup Utility!
  211. echo.
  212. timeout 5
  213. EXIT
  214.  
  215. :CompressErrorChoice
  216. cls
  217. echo ===[Project Zomboid Save Backup Utility]===
  218. echo.
  219. echo.
  220. echo.
  221. set /P c=Due to an Error, Backup Compression failed. Would you like to delete the uncompressed backup[Y/N]?
  222. if /I "%c%" EQU "Y" goto DeleteUncompressed
  223. if /I "%c%" EQU "N" goto Main
  224. goto Main
  225.  
  226. :RestoreErrorChoice
  227. cls
  228. echo ===[Project Zomboid Save Backup Utility]===
  229. echo.
  230. echo.
  231. echo.
  232. set /P c=Due to an Error, Restoration failed. Would you like to clean up the restoration attempt's leftover files[Y/N]?
  233. if /I "%c%" EQU "Y" goto DeleteRestored
  234. if /I "%c%" EQU "N" goto Main
  235. goto Main
  236.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement