Advertisement
Guest User

DRG BACKUP "Rock and SAVE!" [PC]

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