Chrushev

Monster Hunter World PC Save Backup

Aug 13th, 2018
20,321
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ::WRITEN BY DUXA 8/14/2018
  2. ::VERSION 1.5 UPDATED 8/18/2018
  3. ::NOTE: THIS CODE WAS USED ON STEAM BY SOMEONE ELSE AND PRESENTED AS IF IT WAS THEIR OWN. THIS IS NOT ALLOWED UNDER THE COPYRIGHT. PLEASE DO NOT USE ANY OTHER VERSIONS AS THEY MAY CONTAIN MALICIOUS CODE. DMCA COMPLAINT HAS BEEN SUBMITTED AGAINST THOSE PERSONS AND THEIR ACCOUNTS. YOU ARE FREE TO USE THIS CODE AND POST ABOUT IT, AS LONG AS CREDIT TO ORIGINAL AUTHOR (DUXA) AND A LINK IS GIVEN.
  4.  
  5. ::WHAT NEEDS TO BE DONE
  6. :: 1 - Copy/Pasta this whole thing into a text file and end it with .bat, for example "MonsterHunterBackup.bat"
  7. ::     Edit PATH below by replacing XXXXX with your steam user ID. Just follow the path to where the game is
  8. ::     saved and you will see your ID as the name of the folder before you reach 582010 folder.
  9.  
  10. :: OPTIONAL: You can make Windows Scheduler run this script at whatever interval you want.
  11. ::     If CHK below is set to 1 it will only back up saves if there was an actual change to the file.
  12. ::     Alternatively you can run this script in the background while you play without scheduling it. Set TIMER=1
  13. ::     It will ask you how often you want to do backups (in minutes), then just minimize it and let it do backups
  14. ::     while you play.
  15.  
  16. ::     If you have 7zip installed it will be used. If you have WinRar then it will be used. If you have neither
  17. ::     the standard zip will be used. The backups are stored in BACKUPPATH path below. You can change it to whatever
  18. ::     location you want. Note that a log is kept, so that you can go back and see when backups were done. The log is
  19. ::     in the same directory as the backups. Also two text files containing previous/current checksums are kept
  20. ::     there too. They are simple txt files taking up 1kb in space. They are only created if CHK is set to 1.
  21.  
  22. :: For any questions find me on Reddit /u/Chrushev
  23.  
  24. @echo off
  25. SETLOCAL EnableDelayedExpansion
  26. ::================================CHANGE THESE AS NEEDED=====================================
  27.  
  28. ::Location of the saves (replace XXXXX with your user ID)
  29. set PATH=C:\Program Files (x86)\Steam\userdata\XXXXX\582010
  30. ::Location to save the backups to
  31. set BACKUPPATH=%USERPROFILE%\Documents\Monster Hunter World Save Backups
  32. ::Log path
  33. set LOGPATH=%BACKUPPATH%
  34. ::FLAG to do a backup only if save has changed, set to 0 if want to backup no matter what
  35. set /a CHK=1
  36. ::If you dont want to schedule it and instead would like to use this script as something you run while you play
  37. ::in the background then set TIMER=1. It will ask you how often you want to run it (in minutes).
  38. set /a TIMER=0
  39. ::Date format - Possible options are US, EU, YMD. Examples: US 08/17/2018 | EU 17/08/2018 | YMD 2018/08/17
  40. set DATEFORMAT=US
  41. ::If you are not using default path for 7zip or WinRar you can change them here
  42. ::It is ok to not have either, then standard zip format will be used if thats the case
  43. ::Reasons to use 7zip - Better compression, free (WILL BE PREFERRED OVER WINRAR IF INSTALLED)
  44. ::Reasons to use WinRar - Has 5% baked in recovery in case recovery is needed
  45. set SZIPPATH=C:\Program Files\7-Zip
  46. set WRARPATH=C:\Program Files\WinRAR
  47.  
  48. ::============DO NOT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING================
  49. if %DATEFORMAT% == US goto DATEVALID
  50. if %DATEFORMAT% == EU goto DATEVALID
  51. if %DATEFORMAT% == YMD goto DATEVALID
  52. cls
  53. color 0C
  54. echo Invalid date format %DATEFORMAT%
  55. echo Must be either US, EU or YMD
  56. echo.
  57. pause
  58. goto END
  59. :DATEVALID
  60. if %DATEFORMAT% == US set DF=MM-dd-yyyy_HH-mm-ss
  61. if %DATEFORMAT% == EU set DF=dd-MM-yyyy_HH-mm-ss
  62. if %DATEFORMAT% == YMD set DF=yyyy-MM-dd_HH-mm-ss
  63. set /a USESZIP=0
  64. set /a USEWRAR=0
  65. if exist "%SZIPPATH%" (set /a USESZIP=1)
  66. if %USESZIP% EQU 1 goto SKIPWINRAR
  67. if exist "%WRARPATH%" (set /a USEWRAR=1)
  68. :SKIPWINRAR
  69. if %TIMER% == 0 goto SKIPTIMER
  70.  
  71. set /p CLK="How often do you want to backup (enter minutes): "
  72. set /a SECS=%CLK%*60
  73. :SKIPTIMER
  74. if %USESZIP% == 0 goto CHECKWRAR
  75. if exist "%SZIPPATH%\7z.exe" (set SZIPPATH=%SZIPPATH%\7z.exe) else (set SZIPPATH=%SZIPPATH%\7za.exe)
  76. if exist "%SZIPPATH%" (color 0A & echo Found 7zip & goto CHECKPATH)
  77. cls
  78. color 0E
  79. echo WARNING!
  80. echo Cannot find 7-zip in %SZIPPATH%
  81. echo Download it from https://www.7-zip.org/download.html
  82. echo.
  83. echo Checking for WinRar
  84.  
  85. :CHECKWRAR
  86. if exist "%WRARPATH%\rar.exe" (set /a USEWRAR=1 & set /a USESZIP=0 & echo Found WinRar & color 0D) else (color 0F
  87.     echo Could not find 7zip or Winrar
  88.     echo Falling back to standard zip
  89.     set /a USESZIP=0
  90.     set /a USEWRAR=0)
  91.  
  92. :CHECKPATH
  93. if exist "%PATH%" goto CHECKBACKUPPATH
  94. cls
  95. echo ERROR!
  96. echo Cannot find %PATH%
  97. pause
  98. goto END
  99.  
  100. :CHECKBACKUPPATH
  101. if exist "%BACKUPPATH%" goto RUN
  102. mkdir "%BACKUPPATH%"
  103. if exist "%BACKUPPATH%" goto RUN
  104. cls
  105. echo ERROR!
  106. echo Cannot create %BACKUPPATH%
  107. echo To store backups in
  108. echo Need Admin rights?
  109. pause
  110. goto END
  111.  
  112. :RUN
  113. title Monster Hunter Save Backup by Duxa (/u/Chrushev) v1.5 - 8/18/2018
  114. if not exist "%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe" (set /a PWRSH=0) else (set /a PWRSH=1)
  115. if not exist "%BACKUPPATH%\MHW_last_cksum.txt" goto BACKUP
  116. if %CHK% == 0 goto BACKUP
  117.  
  118. "%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_curr_cksum.txt"
  119.    
  120. for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_last_cksum.txt"') do if %%G equ 2 (
  121.     set PREV=%%H)
  122.     set PREV=%PREV: =%
  123.     echo Previous: %PREV%
  124.    
  125. for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_curr_cksum.txt"') do if %%G equ 2 (
  126.     set CURR=%%H)
  127.     set CURR=%CURR: =%
  128.     echo Current:  %CURR%
  129.  
  130. if "%PREV%" == "%CURR%" (
  131.     echo Checksums match. New backup not needed.
  132.     echo %date% %time% - Backup requested, file is same as last time. NOT backing up. >> "%LOGPATH%\MHW_saves_log.txt"
  133.     echo If you would like to backup either way, please set CHK=0 in the file. >> "%LOGPATH%\MHW_saves_log.txt"
  134.     echo Previous: %PREV% >> "%LOGPATH%\MHW_saves_log.txt"
  135.     echo Current:  %CURR% >> "%LOGPATH%\MHW_saves_log.txt"
  136.     echo. >> "%LOGPATH%\MHW_saves_log.txt"
  137.     goto TIMERCHECK
  138. )
  139.  
  140. :BACKUP
  141. if %CHK% == 1 "%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_last_cksum.txt"
  142.  
  143. if %PWRSH% == 1 (for /f %%d in ('%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe get-date -format "{%DF%}"') do set FILENAME=MHW_Save_%%d) else (goto ALTDATE)
  144.  
  145. goto SKIPALTDATE
  146. :ALTDATE
  147. if 20 NEQ %date:~0,2% (set d=%date:~4,10%) else (set d=%date%)
  148. if / == %date:~2,1% (set d=%date%)
  149. if - == %date:~2,1% (set d=%date%)
  150. set tm=%time:~0,8%
  151. set d=%d:/=-% & set tm=%tm::=-%
  152. set tm=%tm:.=-%
  153. set FILENAME=MHW_Save_%d%_%tm%
  154. set FILENAME=%FILENAME: =%
  155. :SKIPALTDATE
  156. if %USESZIP% == 1 ("%SZIPPATH%" a -y "%BACKUPPATH%\%FILENAME%" "%PATH%")
  157. if %USESZIP% == 1 goto NEXT
  158. if %USEWRAR% == 1 ("%WRARPATH%\rar.exe" a -y -ep1 -rr5 "%BACKUPPATH%\%FILENAME%" "%PATH%")
  159. if %USEWRAR% == 1 goto NEXT
  160. "%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe" Compress-Archive -LiteralPath "'%PATH%'" -DestinationPath "'%BACKUPPATH%\%FILENAME%.zip'" -Force
  161. :NEXT
  162. if not exist "%BACKUPPATH%\MHW_curr_cksum.txt" set CURR="N/A - First backup or CHK=0"
  163. if exist "%BACKUPPATH%\%FILENAME%.*" (
  164.     echo Saved %FILENAME% MD5: %CURR%
  165.     echo Saved %FILENAME% MD5: %CURR% >> "%LOGPATH%\MHW_saves_log.txt"
  166.     echo. >> "%LOGPATH%\MHW_saves_log.txt"
  167.     ) else (echo ERROR - CANT CREATE BACKUP "%FILENAME%" >> "%LOGPATH%\MHW_saves_log.txt")
  168. :TIMERCHECK
  169. if %TIMER% == 1 (
  170.     "%SystemRoot%\system32\TIMEOUT" /T %SECS% /NOBREAK
  171.     goto RUN)
  172.  
  173. :END
RAW Paste Data