D2 Backup Script

View previous topic View next topic Go down

D2 Backup Script

Post by WolfieeifloW on Sat Nov 01, 2014 7:12 pm

Diablo II Backup Script
Version: 1.1
By: WolfieeifloW

http://www.mediafire.com/view/eht863qb9oouvbu/d2backup_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:
@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:
v1.1
-Moved %BACKUP_PATH% to above "DO NOT TOUCH..." line.

v1.0
-Initial release


Last edited by WolfieeifloW on Wed Nov 05, 2014 12:43 am; edited 7 times in total

WolfieeifloW
Death Stalker

Boss
Posts : 860
Country : Canada

View user profile

Back to top Go down

Re: D2 Backup Script

Post by GregMXL on Sat Nov 01, 2014 8:22 pm

Cool. Moved to Tools. Have a cookie too. Razz

_____________________
We mortals are but shadows and dust, shadows and dust, Maximus!

GregMXL
Zorun Tzin

Epic Admin
Posts : 13835
TGBest Transferred
Country : United States

View user profile

Back to top Go down

Re: D2 Backup Script

Post by void on Sat Nov 01, 2014 8:34 pm

Cookie of course.
Commented nicely, was a fun read.

void
Prince Albrecht

Cool Font Guy
Posts : 3022
TGBest Transferred
Country : ???

View user profile

Back to top Go down

Re: D2 Backup Script

Post by WolfieeifloW on Mon Nov 03, 2014 12:26 am

Updated
v1.1
-Moved %BACKUP_PATH% to above "DO NOT TOUCH..." line.

WolfieeifloW
Death Stalker

Boss
Posts : 860
Country : Canada

View user profile

Back to top Go down

Re: D2 Backup Script

Post by Quirinus on Tue Nov 04, 2014 10:33 pm

Nice. I'm sure people with multiple comps that they play on will appreciate this. Smile

_____________________
"Zu jeder Zeit, an jedem Ort, bleibt das Tun der Menschen das gleiche."

Quirinus
Creature of Flame

Bloody High Five
Posts : 5567
TGGood none
Country : Croatia

View user profile

Back to top Go down

Re: D2 Backup Script

Post by WolfieeifloW on Wed Nov 05, 2014 12:44 am

Yeah, like I said I switch between Desktop/Laptop, so I use this everyday Smile !
Plus, it can work with any online backup service (Google Drive, Dropbox, etc.).

And the automatic backing up is a nice feature I added, just in case something corrupts in your save folder.

WolfieeifloW
Death Stalker

Boss
Posts : 860
Country : Canada

View user profile

Back to top Go down

Re: D2 Backup Script

Post by 9oel on Tue Nov 25, 2014 2:25 pm

Very useful! Saved my chars from corruption several times allready Clap Clap

9oel
Thunder Beetle

Posts : 14
Country : Sweden

View user profile

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum