per effettuare il salvataggio del database MySQL ho scritto un file SalvaDB.BAT con il parametro timestamp in maniera tale che il file .SQL creato sia riferito alla data e ora attuale.
Eseguendo il file SalvaDB.BAT da riga di comando seguito da una serie di numeri per simulare il timestamp, funziona perfettamente.
Questo è il file SalvaDB.BAT
Code: Select all
@echo off
:: ---- SETUP ----
:: db user name
set dbuser=root
:: db user password
set dbpass=xxxxxxxxx
:: db list (lista di DB separati da uno spazio)
set dblist=apprendistato
:: backup directory destinazione dump
set bkupdir=C:ApprendistatoBackup
:: Cartella di installazione mysql
set mysqldir=C:Program FilesMySQLMySQL Server 8.0
:: Data di sistema
set mydata=%1
:: -----------------------------------------------------
:: NON MODIFICATE SOTTO
echo MySQLDump start >> log.txt
for %%f in (%dblist%) do (
echo backing up %%f ...
"%mysqldir%binmysqldump" --user=%dbuser% --password=%dbpass% --databases %%f --opt --quote-names --allow-keywords --events --routines --complete-insert --skip-lock-tables > "%bkupdir%Apprendistato%mydata%.sql"
echo OK!
echo backup di %%f OK! >> log.txt
)
echo MySQLDump Finito>> log.txt
echo ----- >> log.txt
echo Procedura terminata correttamente!
Code: Select all
METHOD Salva( )
LOCAL sNomeFile AS STRING
LOCAL sParam AS STRING
sNomeFile := "SalvaDB.bat"
SetTimeSep(Asc("_"))
sParam := DToS(Today()) + Time()
SetTimeSep(Asc(":"))
AttivaShellExecute(sNomeFile, sParam)
RETURN NIL
Code: Select all
METHOD AttivaShellExecute(sNomeFile as STRING, sParam as STRING)
LOCAL ptrShEx AS PTR
LOCAL sShEx AS STRING
LOCAL lShEx := FALSE AS LOGIC
ptrShEx := ShellExecute(oApp:handle(), AsPsz("Open"), AsPsz(sNomeFile), ;
AsPsz(sParam), AsPsz(WorkDir()), SW_SHOWNORMAL)
DO CASE
CASE ptrShEx = 0
sShEx := "The operating system is out of memory or resources."
CASE ptrShEx = ERROR_FILE_NOT_FOUND
sShEx := "The specified file was not found."
CASE ptrShEx = ERROR_PATH_NOT_FOUND
sShEx := "The specified path was not found."
CASE ptrShEx = ERROR_BAD_FORMAT
sShEx := "The .EXE file is invalid (non-Win32 .EXE or error in .EXE image)."
CASE ptrShEx = SE_ERR_ACCESSDENIED
sShEx := "The operating system denied access to the specified file."
CASE ptrShEx = SE_ERR_ASSOCINCOMPLETE
sShEx := "The filename association is incomplete or invalid."
CASE ptrShEx = SE_ERR_DDEBUSY
sShEx := "The DDE transaction could not be completed because other DDE transactions were being processed."
CASE ptrShEx = SE_ERR_DDEFAIL
sShEx := "The DDE transaction failed."
CASE ptrShEx = SE_ERR_DDETIMEOUT
sShEx := "The DDE transaction could not be completed because the request timed out."
CASE ptrShEx = SE_ERR_DLLNOTFOUND
sShEx := "The specified dynamic-link library was not found."
CASE ptrShEx = SE_ERR_FNF
sShEx := "The specified file was not found."
CASE ptrShEx = SE_ERR_NOASSOC
sShEx := "There IS no application associated with the given filename extension."
CASE ptrShEx = SE_ERR_OOM
sShEx := "There was not enough memory to complete the operation."
CASE ptrShEx = SE_ERR_PNF
sShEx := "The specified path was not found."
CASE ptrShEx = SE_ERR_SHARE
sShEx := "A sharing violation occurred."
OTHERWISE
lShEx := TRUE
ENDCASE
IF ! lShEx
InfoBox{SELF, "Elaborazione ShellExecute", sShEx}:Show()
ENDIF
RETURN NIL
Qualcuno può aiutarmi?
Grazie