Initial commit
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
@echo off
|
||||
setlocal DisableDelayedExpansion
|
||||
|
||||
REM =========================
|
||||
REM Konfiguracja (parametry)
|
||||
REM =========================
|
||||
set "DB_HOST=172.16.60.3"
|
||||
set "DB_USER=root"
|
||||
set "DB_PASS=admin"
|
||||
set "DB_NAME=softspm_test"
|
||||
|
||||
set "OUT_FILE=spm_dump.sql"
|
||||
set "ERR_FILE=spm_dump.err"
|
||||
|
||||
REM Pelna sciezka do mysqldump.exe (zalecane)
|
||||
set "MYSQLDUMP=C:\Program Files\MariaDB 10.6\bin\mysqldump.exe"
|
||||
|
||||
REM =========================
|
||||
REM Logika
|
||||
REM =========================
|
||||
set "OUT_PATH=%CD%\%OUT_FILE%"
|
||||
set "ERR_PATH=%CD%\%ERR_FILE%"
|
||||
|
||||
echo [INFO] Katalog roboczy: "%CD%"
|
||||
echo [INFO] Plik wyjsciowy: "%OUT_PATH%"
|
||||
|
||||
REM 1) Sprawdz mysqldump
|
||||
if not exist "%MYSQLDUMP%" (
|
||||
echo [ERROR] Nie znaleziono mysqldump.exe pod sciezka:
|
||||
echo "%MYSQLDUMP%"
|
||||
exit /b 2
|
||||
)
|
||||
|
||||
REM 2) Usun poprzedni plik dump (jesli jest)
|
||||
if exist "%OUT_PATH%" (
|
||||
echo [INFO] Usuwam istniejacy plik "%OUT_PATH%"
|
||||
del /f /q "%OUT_PATH%"
|
||||
)
|
||||
|
||||
REM 3) (Opcjonalnie) wyczysc stary plik bledu
|
||||
if exist "%ERR_PATH%" del /f /q "%ERR_PATH%"
|
||||
|
||||
echo [INFO] Wykonuje dump bazy "%DB_NAME%" z hosta %DB_HOST% ...
|
||||
|
||||
REM 4) Dump (stdout -> sql, stderr -> err)
|
||||
"%MYSQLDUMP%" --host=%DB_HOST% --user=%DB_USER% --password="%DB_PASS%" %DB_NAME% 1>"%OUT_PATH%" 2>"%ERR_PATH%"
|
||||
|
||||
if errorlevel 1 (
|
||||
echo [ERROR] Dump nie powiodl sie. Szczegoly w: "%ERR_PATH%"
|
||||
if exist "%OUT_PATH%" del /f /q "%OUT_PATH%"
|
||||
exit /b 4
|
||||
)
|
||||
|
||||
echo [OK] Dump wykonany poprawnie: "%OUT_PATH%"
|
||||
exit /b 0
|
||||
Reference in New Issue
Block a user