summaryrefslogtreecommitdiff
path: root/tools/build_scripts/fixme.cmd
blob: 853815fcdb4b050cb351c0384846c8ead0a87152 (plain)
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
@echo off

if "%1" == "" (
  set /A ProfileCount=0

  pushd %~dp0Profiles

  for /D %%i in (*) do (
    if exist "%~dp0Profiles\%%i\%%i.dat" (
      set ProfileName=%%i
      set /A ProfileCount=%ProfileCount%+1
    )
  )

  popd

) else (
  if not exist "%~dp0Profiles\%1\%1.dat" (
    echo Wrong profile name specified: %1
    goto :eof
  )

  set ProfileName=%1
)

echo Backing up %ProfileName%...

set FullProfileName=.\Profiles\%ProfileName%\%ProfileName%.dat
set TmpFileName=%TEMP%\%ProfileName%.tmp

del "%TmpFileName%" > nul

mdbx_dump.exe -n -a -f "%TmpFileName%" "%FullProfileName%"
if not exist "%TmpFileName%" (
  echo Backup failed, exiting
  goto :eof
)

mdbx_load.exe -n -f "%TmpFileName%" "%FullProfileName%.tmp"
if errorlevel 1 (
  echo Restore failed, exiting
  goto :eof
)

del "%FullProfileName%.bak" > nul
move "%FullProfileName%" "%FullProfileName%.bak"
move "%FullProfileName%.tmp" "%FullProfileName%"

echo Operation succeeded
goto :eof