Hotsammysliz

Monster Hunter Rise PC Save Backup

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