D2 Backup Script

Threads that no longer serve a purpose. Read-only.
User avatar
WolfieeifloW
Bone Archer
76 | 14
Great Popularity Badge
Has a thread with over 50.000 views
Common Guide Badge
Created a complete character guide
There is no 'Tools' section that is able to be posted to, so I'm posting it here.


Diablo II Backup Script
Version: 1.1
By: WolfieeifloW

http://www.mediafire.com/view/eht863qb9 ... up_v11.bat




Hello all.
I play Diablo II on both my desktop and laptop, and manually moving files to my Google Drive between sessions was annoying.
I decided to make this script to do it for me.
I also added the ability to backup to a local backup folder.

Files are backed up to the local backup before being overwritten in the online/save folder.
This is an extra precaution to prevent accidentally overwriting files you didn't want to.


There are 5 configurable lines inside the script, they are at the top under the header "CHANGE YOUR ONLINE SERVICE AND PATHS HERE":
  • ONLINE_ENABLED: Set this to TRUE or FALSE based on if you want to enable backing up/restoring from your online service of choice (Google Drive, Dropbox, etc.)
  • ONLINE_SERVICE: Just type in whatever the name of your online service is
  • SAVE_PATH: This is the path to your save folder inside your D2/D2SE folder*
  • ONLINE_PATH: This is the path to your online services folder*
  • BACKUP_PATH: This is where your backups will be stored*
* - The path does not include the save folder, it is the path to the folder directly below the save folder

(If you do not want to download the file directly, copy and paste this code into a Notepad document, then save it as "d2backup_v11.bat" (Without quotes))

Code: Select all

@ECHO OFF
:HEADER
REM -------------------------------------------------------
REM Program   : d2backup_v11.bat
REM Version   : 1.1
REM Author   : WolfieeifloW
REM Date   : October 31, 2014
REM Purpose   : Backing up / restoring save files for D2
REM -------------------------------------------------------

REM =====================================================
REM ===   CHANGE YOUR ONLINE SERVICE AND PATHS HERE   ===
REM ===   CHANGE YOUR ONLINE SERVICE AND PATHS HERE   ===
REM ===   CHANGE YOUR ONLINE SERVICE AND PATHS HERE   ===
REM =====================================================
REM Change this to TRUE if you want Online things enabled
REM Or set it to FALSE if you do not
SET ONLINE_ENABLED=FALSE

REM Change below to your online services name
SET ONLINE_SERVICE=Google Drive

REM Change the paths below to the correct paths for your folders
REM This is your save folder inside your Diablo II folder
SET SAVE_PATH=C:\Program Files\Diablo II\MODS\Median XL - Ultimative

REM This is your online services folder on your computer
SET ONLINE_PATH=C:\Users\Tinakura\Google Drive

REM A backup folder on your local machine
REM Used for backing up files in case of accidental overwriting
SET BACKUP_PATH=C:\Users\Tinakura\Desktop\D2BackupSaves
REM =====================================================
REM ===    !!! DO NOT TOUCH ANYTHING BELOW HERE !!!   ===
REM ===    !!! DO NOT TOUCH ANYTHING BELOW HERE !!!   ===
REM ===    !!! DO NOT TOUCH ANYTHING BELOW HERE !!!   ===
REM =====================================================


:START
REM Changing title of the command prompt
TITLE Diablo II Backup Script By WolfieeifloW v1.1
REM Clear the prompt, so it resets to just the options list after each option run
CLS
REM Add a line break before options get listed
ECHO.
REM Always show local backup options
ECHO 1: Backup SAVE files TO LOCAL
ECHO 2: Restore SAVE files FROM LOCAL
REM If Online services are enabled, show the online backup options
IF '%ONLINE_ENABLED%'=='TRUE' (
   ECHO 3: Backup SAVE files TO %ONLINE_SERVICE%
   ECHO 4: Restore SAVE files FROM %ONLINE_SERVICE%
   REM With online options, exit is number 5
   ECHO 5: Exit
) ELSE (
   REM Else, without online options, exit is number 3
   ECHO 3: Exit
)

REM Output to choose an option
REM If online is enabled, show there is 5 choices
IF '%ONLINE_ENABLED%'=='TRUE' (
   CHOICE /C:12345 /M "Please choose an option: "
) ELSE (
   REM Else, if online is not enabled, show only 3 choices
   CHOICE /C:123 /M "Please choose an option: "
)


REM After an option is chosen, clear the prompt
CLS
REM Add a line break before options execute
ECHO.

REM Get what option was selected
IF '%ONLINE_ENABLED%'=='TRUE' (
   REM 5 choices if there's online choices
   IF ERRORLEVEL 5 GOTO END
   IF ERRORLEVEL 4 GOTO RESTOREFROMONLINE
   IF ERRORLEVEL 3 GOTO BACKUPTOONLINE
   IF ERRORLEVEL 2 GOTO RESTOREFROMLOCAL
   IF ERRORLEVEL 1 GOTO BACKUPTOLOCAL
) ELSE (
   REM Only 3 choices for no online
   IF ERRORLEVEL 3 GOTO END
   IF ERRORLEVEL 2 GOTO RESTOREFROMLOCAL
   IF ERRORLEVEL 1 GOTO BACKUPTOLOCAL
)
GOTO START


REM Backup SAVE files TO LOCAL
:BACKUPTOLOCAL
REM Display to the user what's happening
ECHO Backing up SAVE files to Local Backup:
REM If the backup local folder doesn't exist
IF NOT EXIST "%BACKUP_PATH%\local" (
   REM Create it
   MKDIR "%BACKUP_PATH%\local"
)
REM Copy save files to local backup
CD %SAVE_PATH%
XCOPY "save" "%BACKUP_PATH%\local" /Y
ECHO.
PAUSE
GOTO START

REM Restore SAVE files FROM LOCAL
:RESTOREFROMLOCAL
REM Display to the user what's happening
ECHO Restoring SAVE files from Local Backup:
REM If the backup local folder doesn't exist
IF NOT EXIST "%BACKUP_PATH%\local" (
   REM Let the user know that there's no files to restore from
   ECHO You have no files in your local backup to restore from!
) ELSE (
   REM Else, if the local backup folder does exist
   REM Restore save files from local backup
   CD %BACKUP_PATH%
   XCOPY "local" "%SAVE_PATH%\save" /Y
)
ECHO.
PAUSE
GOTO START

REM Backup SAVE files TO ONLINE
:BACKUPTOONLINE
REM Display to the user what's happening
ECHO Backing up SAVE files to %ONLINE_SERVICE%:
REM If the backup online folder doesn't exist
IF NOT EXIST "%BACKUP_PATH%\online" (
   REM Create it
   MKDIR "%BACKUP_PATH%\online"
) ELSE (
   REM Else, if the backup online folder does exist
   CD %ONLINE_PATH%
   REM Backup online files to online backup
   XCOPY "save" "%BACKUP_PATH%\online" /Q /Y > nul
)
REM If the online folder doesn't exist
IF NOT EXIST "%ONLINE_PATH%\save" (
   REM Create it
   MKDIR "%ONLINE_PATH%\save"
)
REM Backup save files to online
CD %SAVE_PATH%
XCOPY "save" "%ONLINE_PATH%\save" /Y
ECHO.
PAUSE
GOTO START

REM Restore SAVE files FROM ONLINE
:RESTOREFROMONLINE
REM If the online folder doesn't exist
IF NOT EXIST "%ONLINE_PATH%\save" (
   REM Display to the user what's happening
   ECHO Restoring SAVE files from %ONLINE_SERVICE%:
   REM Let the user know that there's no files to restore from
   ECHO You have no files in your online service to restore from!
) ELSE (
   REM Else, if the online folder does exist
   REM If the backup local folder doesn't exist
   IF NOT EXIST "%BACKUP_PATH%\local" (
      REM Create it
      MKDIR "%BACKUP_PATH%\local"
   )
   REM Display to the user what's happening
   ECHO Restoring SAVE files from %ONLINE_SERVICE%:
   CD %SAVE_PATH%
   REM Backup save files to local backup first
   XCOPY "save" "%BACKUP_PATH%\local" /Q /Y >nul
   REM Restore save from online
   CD %ONLINE_PATH%
   XCOPY "save" "%SAVE_PATH%\save" /Y
)
ECHO.
PAUSE
GOTO START


:END
ECHO.
ECHO Exiting script, press any key...
PAUSE >nul
:: Exit and return errorcode of 0
EXIT /B 0

Any constructive criticism is welcome, flaming is not.


Changelog
► Show Spoiler