-
Notifications
You must be signed in to change notification settings - Fork 2
/
RestoreServerBackup.bat
56 lines (45 loc) · 1.13 KB
/
RestoreServerBackup.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@ECHO OFF
:: Optional - edit the restored world name ::
set worlddir="RestoredWorld"
:: Optional - manually select backup folder (default is latest) ::
set backupdir=""
:: Don't edit past this point ::
for /f "tokens=*" %%f in (
'dir /b mods\Backups-*.jar'
) do (
set modname=%%f
goto :foundmod
)
echo Backups mod was not found
goto :done
:foundmod
set modpath="mods\%modname%"
if not %backupdir%=="" goto :restorebackup
if exist backupsmod (
set mainbackupsdir=backupsmod
) else if exist backups (
set mainbackupsdir=backups
) else (
echo No backups were found
goto :done
)
for /f "tokens=*" %%a in (
'dir /b /ad-h /t:c /o-d "%mainbackupsdir%"'
) do for /f "tokens=*" %%b in (
'dir /b /ad-h /t:c /o-d "%mainbackupsdir%\%%a"'
) do (
set latestworld=%%a
set latestsave=%%b
goto :foundbackup
)
echo No backups were found
goto :done
:foundbackup
set backupdir="%mainbackupsdir%\%latestworld%\%latestsave%"
:restorebackup
java -jar %modpath% %backupdir% %worlddir%
if %errorlevel%==0 (
echo World backup successfully restored to %worlddir% from %backupdir%
)
:done
PAUSE