Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ::WRITEN BY DUXA 8/14/2018
  2.  
  3. ::WHAT NEEDS TO BE DONE
  4. :: 1 - Download 7zip CMD verson. Its the 3rd link down on 7zip downloads or use direct link
  5. ::     https://www.7-zip.org/a/7z1805-extra.7z and place it either in C:\7z_console or elsewhere
  6. ::     but if you place it elsewhere then you need to change the SZIPPATH path below
  7.  
  8. ::     Windows does not have compresion via CMD by default, and not using compression would be silly since 9MB file
  9. ::     is compressed down to ~30kb. Thats 99.7% compression. 7zip was chosen because its free and very good.
  10. ::     Note: If you already have 7zip you can change the path to point to it, but note non cmd version is 7z.exe not 7za.exe
  11. ::     so you will need to adjust that on line 92.
  12.  
  13. :: 2 - Copy/Pasta this whole thing into a text file and end it with .bat, for example "MonsterHunterBackup.bat"
  14. ::     Edit paths below by replacing XXXXX with your steam user ID. Just follow the path to where the game is
  15. ::     saved and you will see your ID as the name of the folder before you reach 582010 folder.
  16. ::     No way for me to know what your ID is so you gotta do this yourself.
  17. ::     NOTE: Non Windows 10 users change CHK=1 to be CHK=0 below. Non Win10 support is possible but I think most are on Win10
  18.  
  19. :: 3 - OPTIONAL: you can make Windows Scheduler run this script at whatever interval you want, backup every
  20. ::     10 minutes? No problem, every hour? No problem. If CHK below is set to 1 it will only back up saves if
  21. ::     there was an actual change to the file.
  22. ::     I noticed save file changes upon loading and upon saving. Quitting without saving does not modify it.
  23. ::     If you are not on Windows 10 you can not use this due to different formatting on previous Win versions.
  24. ::     So if you are on Windows 7 you can still use the backup functionality, but you just have to set CHK to 0
  25. ::     so it will backup every time you or scheduler runs it.
  26.  
  27. ::     By default the backups are saved as .7z files in BACKUPPATH path below (your user folder)
  28. ::     You can change it by editing BACKUPPATH.
  29. ::     Note that a log is kept, so that you can go back and see when backups were done. They will
  30. ::     be in the same directory as the backups. Also two text files containing previous/current checksums are kept
  31. ::     there too. They are simple txt files taking up 1kb in space. They are only created if CHK is set to 1.
  32.  
  33. :: For any questions find me on Reddit /u/Chrushev
  34.  
  35. @echo off
  36. :: CHANGE THESE AS NEEDED
  37.  
  38. ::Location of the saves (replace XXXXX with your user ID)
  39. set PATH=C:\Program Files (x86)\Steam\userdata\102139856\582010\remote
  40. ::Location to save the file to. (replace XXXXX with your user ID)
  41. set BACKUPPATH=C:\Program Files (x86)\Steam\userdata\102139856
  42. ::Location of 7zip cmd version (can be obtained from https://www.7-zip.org/a/7z1805-extra.7z)
  43. set SZIPPATH=C:\7z_console
  44. ::Log path (by default uses the same path as the backups)
  45. set LOGPATH=%BACKUPPATH%
  46. ::FLAG to check only if save file changed, set to 0 if want to backup no matter what
  47. ::THIS ONLY WORKS ON WINDOWS 10 due to formatting! TURN OFF OTHERWISE BY SETTING TO 0
  48. set /a CHK=1
  49.  
  50. ::DO NOT CHANGE ANYTHING UNDERNEATH UNLESS YOU KNOW WHAT YOU ARE DOING
  51. if exist "%SZIPPATH%" goto CHECKPATH
  52. color 0C
  53. echo ERROR!
  54. echo Cannot find 7-zip
  55. echo Download the cmd version from https://www.7-zip.org/download.html
  56. echo and place it in the path listed above.
  57. pause
  58. goto END
  59.  
  60. :CHECKPATH
  61. if exist "%PATH%" goto RUN
  62. echo ERROR!
  63. echo Cannot find %PATH%
  64. pause
  65. goto END
  66.  
  67. :RUN
  68. if not exist "%BACKUPPATH%\MHW_last_cksum.txt" goto BACKUP
  69. if %CHK% == 0 goto BACKUP
  70.  
  71. "%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_curr_cksum.txt"
  72.    
  73. for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_last_cksum.txt"') do if %%G equ 2 (
  74.     echo Previous: %%H
  75.     set PREV=%%H)
  76.    
  77. for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_curr_cksum.txt"') do if %%G equ 2 (
  78.     echo Current:  %%H
  79.     set CURR=%%H)
  80.    
  81. if "%PREV%" == "%CURR%" (
  82.     echo Checksums match. New backup NOT needed.
  83.     echo %date% %time% - Backup requested, file is same as last time. NOT backing up. >> "%LOGPATH%\MHW_saves_log.txt"
  84.     echo If you would like to backup either way, please set CHK=0 in the script. >> "%LOGPATH%\MHW_saves_log.txt"
  85.     goto END
  86. )
  87.  
  88. :BACKUP
  89. if %CHK% == 1 "%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_last_cksum.txt"
  90.  
  91. set FILENAME=MHW_Save_%date:~4,2%-%date:~7,2%-%date:~10,4%_%time:~0,2%-%time:~3,2%-%time:~6,2%
  92. "%SZIPPATH%\7za.exe" a -y "%BACKUPPATH%\%FILENAME%" "%PATH%"
  93. if exist "%BACKUPPATH%\%FILENAME%.7z" echo Saved %FILENAME% >> "%LOGPATH%\MHW_saves_log.txt"
  94.  
  95. :END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement