Jump to content

Robocopy, Backing up with batch file.

Marfe

Good day!

 

I want to create a batch file to back up my save game on Monster Hunter World but I don't exactly know how batch files work.

Currently this is my batch file

 

robocopy D:\Test D:\Output

 

In the first copy it goes ok but when I try to run the batch file again it does nothing.

 

How can I delete the file on the output folder then copy again the file on the test folder.

CPU: Ryzen 5 1600, Ryzen 5 3600

Motherboard: MSI B350M Bazooka, ASUS X570 Tuf Gaming-Plus

GPU: MSI GTX 1060 3GB Aero ITX OC, MSI RTX 2070 Gaming Z

Ram: Corsair LPX 2x8GB 3000mhz DDR4

PSU: Antec Neo Eco 650W 80+ Bronze, Corsair RM750x

Storage:

• Samsung 850 Evo 250GB (Boot Drive)

• Samsung 860 Evo 500GB (Steam Library)

• Western Digital Blue 1TB (Anything Library)

Cooling: Hyper 212X, NZXT X72

Case: Silencio 352, MasterBox 5 White (Mesh)

Link to comment
Share on other sites

Link to post
Share on other sites

you need to pass the /MIR flag

for example, robocopy /MIR D:\Test D:\Output

This will make the output match the source by copying any new files, updating any existing ones (if necessary), and deleting ones form the destination that no longer exist in the source.

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Ryan_Vickers said:

you need to pass the /MIR flag

for example, robocopy /MIR D:\Test D:\Output

This will make the output match the source by copying any new files, updating any existing ones (if necessary), and deleting ones form the destination that no longer exist in the source.

I just used xcopy instead.

 

xcopy D:\Test D:\Output /e

 

Now how can I automatically overwrite files? because if I ran the batch file again it will ask if i want to overwrite files. Is there a way to always say yes to it?

 

image.png.0caac21e639911624e1b18e40d50590e.png

CPU: Ryzen 5 1600, Ryzen 5 3600

Motherboard: MSI B350M Bazooka, ASUS X570 Tuf Gaming-Plus

GPU: MSI GTX 1060 3GB Aero ITX OC, MSI RTX 2070 Gaming Z

Ram: Corsair LPX 2x8GB 3000mhz DDR4

PSU: Antec Neo Eco 650W 80+ Bronze, Corsair RM750x

Storage:

• Samsung 850 Evo 250GB (Boot Drive)

• Samsung 860 Evo 500GB (Steam Library)

• Western Digital Blue 1TB (Anything Library)

Cooling: Hyper 212X, NZXT X72

Case: Silencio 352, MasterBox 5 White (Mesh)

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, Marfe said:

I just used xcopy instead.

 

xcopy D:\Test D:\Output /e

 

Now how can I automatically overwrite files? because if I ran the batch file again it will ask if i want to overwrite files. Is there a way to always say yes to it?

 

I have no experience with xcopy.  robocopy would automatically do this with the settings I gave above

Solve your own audio issues  |  First Steps with RPi 3  |  Humidity & Condensation  |  Sleep & Hibernation  |  Overclocking RAM  |  Making Backups  |  Displays  |  4K / 8K / 16K / etc.  |  Do I need 80+ Platinum?

If you can read this you're using the wrong theme.  You can change it at the bottom.

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Ryan_Vickers said:

I have no experience with xcopy.  robocopy would automatically do this with the settings I gave above

i figured it out. Thanks

 

xcopy D:\Test D:\Output /e /y

CPU: Ryzen 5 1600, Ryzen 5 3600

Motherboard: MSI B350M Bazooka, ASUS X570 Tuf Gaming-Plus

GPU: MSI GTX 1060 3GB Aero ITX OC, MSI RTX 2070 Gaming Z

Ram: Corsair LPX 2x8GB 3000mhz DDR4

PSU: Antec Neo Eco 650W 80+ Bronze, Corsair RM750x

Storage:

• Samsung 850 Evo 250GB (Boot Drive)

• Samsung 860 Evo 500GB (Steam Library)

• Western Digital Blue 1TB (Anything Library)

Cooling: Hyper 212X, NZXT X72

Case: Silencio 352, MasterBox 5 White (Mesh)

Link to comment
Share on other sites

Link to post
Share on other sites

I know you got it working, but someone on reddit made a bat script that backs up the save data, and is very complex.

::WRITEN BY DUXA 8/14/2018
::VERSION 1.5 UPDATED 8/18/2018
 
::WHAT NEEDS TO BE DONE
:: 1 - Copy/Pasta this whole thing into a text file and end it with .bat, for example "MonsterHunterBackup.bat"
::     Edit PATH below by replacing XXXXX with your steam user ID. Just follow the path to where the game is
::     saved and you will see your ID as the name of the folder before you reach 582010 folder.
 
:: OPTIONAL: You can make Windows Scheduler run this script at whatever interval you want.
::     If CHK below is set to 1 it will only back up saves if there was an actual change to the file.
::     Alternatively you can run this script in the background while you play without scheduling it. Set TIMER=1
::     It will ask you how often you want to do backups (in minutes), then just minimize it and let it do backups
::     while you play.
 
::     If you have 7zip installed it will be used. If you have WinRar then it will be used. If you have neither
::     the standard zip will be used. The backups are stored in BACKUPPATH path below. You can change it to whatever
::     location you want. Note that a log is kept, so that you can go back and see when backups were done. The log is
::     in the same directory as the backups. Also two text files containing previous/current checksums are kept
::     there too. They are simple txt files taking up 1kb in space. They are only created if CHK is set to 1.
 
:: For any questions find me on Reddit /u/Chrushev
 
@echo off
SETLOCAL EnableDelayedExpansion
::================================CHANGE THESE AS NEEDED=====================================
 
::Location of the saves (replace XXXXX with your user ID)
set PATH=C:\Program Files (x86)\Steam\userdata\67876838\582010\remote
::Location to save the backups to
set BACKUPPATH=%USERPROFILE%\Documents\Monster Hunter World Save Backups
::Log path
set LOGPATH=%BACKUPPATH%
::FLAG to do a backup only if save has changed, set to 0 if want to backup no matter what
set /a CHK=1
::If you dont want to schedule it and instead would like to use this script as something you run while you play
::in the background then set TIMER=1. It will ask you how often you want to run it (in minutes).
set /a TIMER=0
::Date format - Possible options are US, EU, YMD. Examples: US 08/17/2018 | EU 17/08/2018 | YMD 2018/08/17
set DATEFORMAT=US
::If you are not using default path for 7zip or WinRar you can change them here
::It is ok to not have either, then standard zip format will be used if thats the case
::Reasons to use 7zip - Better compression, free (WILL BE PREFERRED OVER WINRAR IF INSTALLED)
::Reasons to use WinRar - Has 5% baked in recovery in case recovery is needed
set SZIPPATH=C:\Program Files\7-Zip
set WRARPATH=C:\Program Files\WinRAR
 
::============DO NOT CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING================
if %DATEFORMAT% == US goto DATEVALID
if %DATEFORMAT% == EU goto DATEVALID
if %DATEFORMAT% == YMD goto DATEVALID
cls
color 0C
echo Invalid date format %DATEFORMAT%
echo Must be either US, EU or YMD
echo.
pause
goto END
:DATEVALID
if %DATEFORMAT% == US set DF=MM-dd-yyyy_HH-mm-ss
if %DATEFORMAT% == EU set DF=dd-MM-yyyy_HH-mm-ss
if %DATEFORMAT% == YMD set DF=yyyy-MM-dd_HH-mm-ss
set /a USESZIP=0
set /a USEWRAR=0
if exist "%SZIPPATH%" (set /a USESZIP=1)
if %USESZIP% EQU 1 goto SKIPWINRAR
if exist "%WRARPATH%" (set /a USEWRAR=1)
:SKIPWINRAR
if %TIMER% == 0 goto SKIPTIMER
 
set /p CLK="How often do you want to backup (enter minutes): "
set /a SECS=%CLK%*60
:SKIPTIMER
if %USESZIP% == 0 goto CHECKWRAR
if exist "%SZIPPATH%\7z.exe" (set SZIPPATH=%SZIPPATH%\7z.exe) else (set SZIPPATH=%SZIPPATH%\7za.exe)
if exist "%SZIPPATH%" (color 0A & echo Found 7zip & goto CHECKPATH)
cls
color 0E
echo WARNING!
echo Cannot find 7-zip in %SZIPPATH%
echo Download it from https://www.7-zip.org/download.html
echo.
echo Checking for WinRar
 
:CHECKWRAR
if exist "%WRARPATH%\rar.exe" (set /a USEWRAR=1 & set /a USESZIP=0 & echo Found WinRar & color 0D) else (color 0F
    echo Could not find 7zip or Winrar
    echo Falling back to standard zip
    set /a USESZIP=0
    set /a USEWRAR=0)
 
:CHECKPATH
if exist "%PATH%" goto CHECKBACKUPPATH
cls
echo ERROR!
echo Cannot find %PATH%
pause
goto END
 
:CHECKBACKUPPATH
if exist "%BACKUPPATH%" goto RUN
mkdir "%BACKUPPATH%"
if exist "%BACKUPPATH%" goto RUN
cls
echo ERROR!
echo Cannot create %BACKUPPATH%
echo To store backups in
echo Need Admin rights?
pause
goto END
 
:RUN
title Monster Hunter Save Backup by Duxa (/u/Chrushev) v1.5 - 8/18/2018
if not exist "%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe" (set /a PWRSH=0) else (set /a PWRSH=1)
if not exist "%BACKUPPATH%\MHW_last_cksum.txt" goto BACKUP
if %CHK% == 0 goto BACKUP
 
"%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_curr_cksum.txt"
   
for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_last_cksum.txt"') do if %%G equ 2 (
    set PREV=%%H)
    set PREV=%PREV: =%
    echo Previous: %PREV%
   
for /f "tokens=1*delims=:" %%G in ('%SystemRoot%\system32\findstr /n "^" "%BACKUPPATH%\MHW_curr_cksum.txt"') do if %%G equ 2 (
    set CURR=%%H)
    set CURR=%CURR: =%
    echo Current:  %CURR%
 
if "%PREV%" == "%CURR%" (
    echo Checksums match. New backup not needed.
    echo %date% %time% - Backup requested, file is same as last time. NOT backing up. >> "%LOGPATH%\MHW_saves_log.txt"
    echo If you would like to backup either way, please set CHK=0 in the file. >> "%LOGPATH%\MHW_saves_log.txt"
    echo Previous: %PREV% >> "%LOGPATH%\MHW_saves_log.txt"
    echo Current:  %CURR% >> "%LOGPATH%\MHW_saves_log.txt"
    echo. >> "%LOGPATH%\MHW_saves_log.txt"
    goto TIMERCHECK
)
 
:BACKUP
if %CHK% == 1 "%SystemRoot%\system32\CertUtil" -hashfile "%PATH%\remote\SAVEDATA1000" MD5 > "%BACKUPPATH%\MHW_last_cksum.txt"
 
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)
 
goto SKIPALTDATE
:ALTDATE
if 20 NEQ %date:~0,2% (set d=%date:~4,10%) else (set d=%date%)
if / == %date:~2,1% (set d=%date%)
if - == %date:~2,1% (set d=%date%)
set tm=%time:~0,8%
set d=%d:/=-% & set tm=%tm::=-%
set tm=%tm:.=-%
set FILENAME=MHW_Save_%d%_%tm%
set FILENAME=%FILENAME: =%
:SKIPALTDATE
if %USESZIP% == 1 ("%SZIPPATH%" a -y "%BACKUPPATH%\%FILENAME%" "%PATH%")
if %USESZIP% == 1 goto NEXT
if %USEWRAR% == 1 ("%wRARPATH%\rar.exe" a -y -ep1 -rr5 "%BACKUPPATH%\%FILENAME%" "%PATH%")
if %USEWRAR% == 1 goto NEXT
"%SystemRoot%\system32\WindowsPowerShell\v1.0\PowerShell.exe" Compress-Archive -LiteralPath "'%PATH%'" -DestinationPath "'%BACKUPPATH%\%FILENAME%.zip'" -Force
:NEXT
if not exist "%BACKUPPATH%\MHW_curr_cksum.txt" set CURR="N/A - First backup or CHK=0"
if exist "%BACKUPPATH%\%FILENAME%.*" (
    echo Saved %FILENAME% MD5: %CURR%
    echo Saved %FILENAME% MD5: %CURR% >> "%LOGPATH%\MHW_saves_log.txt"
    echo. >> "%LOGPATH%\MHW_saves_log.txt"
    ) else (echo ERROR - CANT CREATE BACKUP "%FILENAME%" >> "%LOGPATH%\MHW_saves_log.txt")
:TIMERCHECK
if %TIMER% == 1 (
    "%SystemRoot%\system32\TIMEOUT" /T %SECS% /NOBREAK
    goto RUN)
 
:END

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×