Hi,
Do you know if is it possible to restore only one table from backup did using the function BACKUP of the TDolphin ? How to do ?
#include "FiveWin.ch"
#include "directry.ch"
static oTimerTime
function main
local odp,of1,of2
private osay1,osay2,osay3,osay4,ometer1,ometer2,ometer3
set date brit
set century on
set epoch to 1990
define dialog odp resource "main" title "Backup do Sistema"
odp:lhelpicon:=.f.
redefine BITMAP of1 id 350 OF odp filename "BACK.BMP" ADJUST
redefine BITMAP of2 id 351 OF odp filename "MYSQL.BMP" ADJUST
redefine button id 21 of odp action backup()
redefine button id 22 of odp action restore()
redefine button id 23 of odp action config()
redefine button id 24 of odp action odp:end()
activate dialog odp centered
of1:end()
of2:end()
return nil
function backup
local oDlg, oLbx, cDrive := "", oBtn,user,senh,tp,ip,banc,tp_bk,ccurdir,ogh,vgh
private atu_w,ip_w,banc_w,usu_w,senha_w
private nAmount1:=nAmount2:=namount3:=0,cComando,ob1,ob2,ob3,cami,nombkp
cCurDir := ( CurDrive()+":\"+CurDir()+"\" )
if file(cCurDir+"BACKUP.INI")
* le do ini
INI oIni FILE (ccurdir+"BACKUP.INI")
GET user SECTION "CONECTION" ENTRY "UserName" OF oIni
GET senh SECTION "CONECTION" ENTRY "Password" OF oIni
GET tp SECTION "CONECTION" ENTRY "Tipo" OF oIni
GET ip SECTION "CONECTION" ENTRY "IP_SERV" OF oIni
GET banc SECTION "CONECTION" ENTRY "BANC" OF oIni
GET cami SECTION "CONECTION" ENTRY "caminho" OF oIni
GET tp_bk SECTION "CONECTION" ENTRY "tp_bk" OF oIni
GET atu_w SECTION "CONECTION" ENTRY "atu_web" OF oIni
GET ip_w SECTION "CONECTION" ENTRY "ip_web" OF oIni
GET banc_w SECTION "CONECTION" ENTRY "banc_web" OF oIni
GET usu_w SECTION "CONECTION" ENTRY "usu_web" OF oIni
GET senha_w SECTION "CONECTION" ENTRY "senha_web" OF oIni
ENDINI
user:=substr(decrypt(alltrim(user))+space(50),1,50)
senh:=substr(alltrim(decrypt(senh))+space(50),1,50)
ip :=substr(alltrim(ip)+space(19),1,19)
banc:=substr(alltrim(banc)+space(50),1,50)
* pega nome do arquivo de backup
nombkp:=qnome(tp_bk)
if tp="LOCAL"
* cComando:='mysqldump.exe --opt -u '+user +' -p'+ senh + ' --database '+banc +' > '+nombkp+' '+CRLF
cComando:='mysqldump.exe --opt -u '+user +' -p'+ senh + ' '+banc +' > '+nombkp+' '+CRLF
else
* cComando:='mysqldump.exe --opt -h '+ ip +' -u '+ user +' -p'+senh +' --database '+banc+ ' > '+nombkp+' '+CRLF
cComando:='mysqldump.exe --opt -h '+ ip +' -u '+ user +' -p'+senh +' '+banc+ ' > '+nombkp+' '+CRLF
endif
else
msgstop(oemtoansi("Arquivo de Configura‡Æo nÆo encontrado !"),"Erro")
return nil
endif
vgh:=verif_cami(cami,nombkp)
DEFINE DIALOG oDlg RESOURCE "protect2" TITLE "Backup do Sistema"
odlg:lhelpicon:=.f.
REDEFINE BUTTON ob2 ID 25 OF oDlg ACTION iif(Check( odlg ),odlg:end() , )
REDEFINE BUTTON ob3 ID 50 OF oDlg ACTION oDlg:End()
REDEFINE SAY oSay1 ID 110 OF oDlg
REDEFINE SAY oSay2 ID 120 OF oDlg
REDEFINE SAY oSay3 ID 140 OF oDlg
REDEFINE SAY oSay4 ID 141 OF oDlg
redefine get ogh var vgh id 26 of odlg picture "@X" valid !empty(vgh) color CLR_BLACK,CLR_WHITE
redefine button id 27 of odlg action ol:=cgetdir("Escolha o Local desejado",cami,,"GRAVAR ARQUIVO DE BACKUP"),iif(!empty(ol),(cami:=ol, vgh:=verif_cami(cami,nombkp) , ogh:refresh() ) , )
redefine say id 182 of odlg prompt "Local a ser Gravado o Backup"
REDEFINE METER oMeter1 VAR nAmount1 ID 130 OF oDlg
REDEFINE METER oMeter2 VAR nAmount2 ID 150 OF oDlg
REDEFINE METER oMeter3 VAR nAmount3 ID 151 OF oDlg
ometer3:nclrbar:=CLR_GREEN
ometer3:lpercentage:=.f.
ACTIVATE DIALOG oDlg CENTERED
ferase(nombkp)
return nil
function verif_cami(cami,nombk)
local vol,tam
cami:=alltrim(cami)
tam:=len(cami)
if substr(cami,tam,1)<>"\"
cami:=cami+"\"
endif
vol:=cami+nombk
return vol
function Check( odlg)
local cInfo
cdrive:=alltrim(cami)
disablex(odlg)
ob2:disable()
ob3:disable()
* faz o backup
fpbackup(cdrive)
ob2:enable()
ob3:enable()
return .t.
static function fpBackup(cdrive)
local lEnd := .f.
local nBufSize := 4000,oldt,tfim
* verifica se o pendrive esta ok
if !pen_ok(cdrive)
msgstop(oemtoansi("Problemas no Destino da grava‡Æo ! Verifique !"),"Erro")
return nil
endif
namount3:=0
oudt:=time()
ativa_timer(.t.)
oSay4:SetText( "Aguarde, Preparando dados...." )
oMeter3:nTotal = 100
* roda o mysqldump
myrun(cComando)
oSay4:SetText( "Tempo gasto: "+elaptime( oudt ,time()) )
ativa_timer(.f.)
* manda para a internet
if atu_w = "S"
sysrefresh()
namount3:=0
ativa_timer(.t.)
oSay4:SetText( "Aguarde, Transmitindo para a Internet...." )
oMeter3:nTotal = 100
* ccomando:="mysql.exe -h "+ip_w+" -u "+usu_w+" -p"+senha_w+" "+banc_w +" < "+nombkp
ccomando:="mysql.exe -u "+usu_w+" -p"+senha_w+" --host="+ip_w +" -C "+banc_w +" < "+nombkp
***ccomando1:="mysql.exe -h 187.17.103.145 -u fbaluminar1 -pfazenda2011 fbaluminar1 < backup.sql "
* roda o mysqldump
myrun(cComando)
oSay4:SetText( "Tempo gasto: "+elaptime( oudt ,time()) )
ativa_timer(.f.)
endif
* verifica se o pendrive esta ok
if !pen_ok(cdrive)
msgstop(oemtoansi("Problemas no Destino da Grava‡Æo ! Verifique !"),"Erro")
return nil
endif
asource:= { nombkp }
aTarget:= { verif_cami(cdrive,nombkp) }
StartCopy( aSource, aTarget, nBufSize,;
oSay1, oSay2, oMeter1, oSay3, oMeter2,;
@lEnd )
tfim:=time()
oSay3:SetText( "Tempo Total gasto: "+elaptime( oudt , tfim ) )
msgalert( 'Backup Completado Com Sucesso !'+CRLF+CRLF+ ;
"Tempo Total gasto: "+elaptime( oudt , tfim ) ,'Aviso' )
return .t.
FUNCTION myRUN( cComando, nStyle, lWait, lShowResult )
local oShell, RET
IF valtype( nStyle ) != "N"
nStyle := 0
ENDIF
IF ValType( lWait ) != "L"
lWait := .T.
ENDIF
IF ValType( lShowResult ) != "L"
lShowResult := .F.
ENDIF
oShell := CreateObject( "WScript.Shell" )
IF !GetEnv( "OS" ) == "Windows_NT"
cComando += "start " + cComando
ENDIF
RET := oShell:Run( "%comspec% /c " + cComando, nStyle, lWait )
IF lShowResult .AND. RET > 0 .and. RET <= 32
msginfo( "Erro Win_Run(): " + ltrim( Str( RET ) ), " OK " )
ENDIF
oShell := NIL
Return IF( RET = 0, .T., .F. )
static function StartCopy( aSource, aTarget, nBufSize, oSay1, oSay2,;
oMeter1, oSay3, oMeter2, lEnd)
local n
local hSource, hTarget
local cBuffer := Space( nBufSize )
local nBytes, nFile := 0, nTotal := 0
local nTotSize := 0
for n = 1 to Len( aSource )
if ! File( aSource[ n ] )
MsgStop( "Arquivo nao Encontrado: " + aSource[ n ] )
exit
endif
hSource = FOpen( aSource[ n ] )
nTotSize += FSeek( hSource, 0, 2 )
FClose( hSource )
SysRefresh()
next
oMeter2:nTotal = nTotSize
for n = 1 to Len( aSource )
hSource = FOpen( aSource[ n ] )
hTarget = FCreate( aTarget[ n ] )
oSay1:SetText( "Origem: " + aSource[ n ] )
oSay2:SetText( "Destino: " + aTarget[ n ] )
oMeter1:Set( 0 )
oMeter1:nTotal = FSeek( hSource, 0, 2 )
FSeek( hSource, 0, 0 )
nFile := 0
SysRefresh()
while ( nBytes := FRead( hSource, @cBuffer, nBufSize ) ) > 0
FWrite( hTarget, cBuffer, nBytes )
oSay3:SetText( "Bytes copiados: " + ;
AllTrim( Str( nTotal += nBytes ) ) )
oMeter1:Set( nFile += nBytes )
oMeter2:Set( nTotal )
SysRefresh()
end
FClose( hSource )
FClose( hTarget )
if lEnd
exit
endif
next
return nil
function config
local od2,faz:=.f.,vchk[5],ochk[5],oini,elocal,tserv,vs,ol
private vg[11],og[11],vsf[4]
cCurDir := ( CurDrive()+":\"+CurDir()+"\" )
if file(cCurDir+"BACKUP.INI")
* le do ini
INI oIni FILE (ccurdir+"BACKUP.INI")
GET vg[2] SECTION "CONECTION" ENTRY "UserName" OF oIni
GET vg[3] SECTION "CONECTION" ENTRY "Password" OF oIni
GET tserv SECTION "CONECTION" ENTRY "Tipo" OF oIni
GET vg[4] SECTION "CONECTION" ENTRY "IP_SERV" OF oIni
GET vg[1] SECTION "CONECTION" ENTRY "BANC" OF oIni
GET vg[5] SECTION "CONECTION" ENTRY "caminho" OF oIni
GET vg[6] SECTION "CONECTION" ENTRY "tp_bk" OF oIni
GET vg[7] SECTION "CONECTION" ENTRY "atu_web" OF oIni
GET vg[8] SECTION "CONECTION" ENTRY "ip_web" OF oIni
GET vg[9] SECTION "CONECTION" ENTRY "banc_web" OF oIni
GET vg[10] SECTION "CONECTION" ENTRY "usu_web" OF oIni
GET vg[11] SECTION "CONECTION" ENTRY "senha_web" OF oIni
ENDINI
vg[2]:=substr(decrypt(alltrim(vg[2]))+space(50),1,50)
vg[3]:=substr(alltrim(decrypt(vg[3]))+space(50),1,50)
vg[4]:=substr(alltrim(vg[4])+space(19),1,19)
vg[1]:=substr(alltrim(vg[1])+space(50),1,50)
vg[5]:=substr(alltrim(vg[5])+space(50),1,50)
vg[8]:=substr(alltrim(vg[8])+space(19),1,19)
vg[9]:=substr(alltrim(vg[9])+space(40),1,40)
vg[10]:=substr(alltrim(vg[10])+space(40),1,40)
vg[11]:=substr(alltrim(vg[11])+space(40),1,40)
if vg[6]="1"
vchk[3]:=.t.
vchk[4]:=.f.
else
vchk[3]:=.f.
vchk[4]:=.t.
endif
if vg[7]="S"
vchk[5]:=.t.
else
vchk[5]:=.f.
endif
else
tserv:="LOCAL"
vg:={ space(50),;
space(50),;
space(50),;
" ",;
space(50),;
"1",;
"N",;
" ",;
space(40),;
space(40),;
space(40) }
vchk[3]:=.t.
vchk[4]:=.f.
vchk[5]:=.f.
endif
if empty(vg[4])
vg[4]:=" "
endif
if tserv="LOCAL"
elocal:=.t.
vchk[1]:=.t.
vchk[2]:=.f.
else
elocal:=.f.
vchk[1]:=.f.
vchk[2]:=.t.
endif
define dialog od2 resource "config" title oemtoansi("Configura‡Æo do Backup")
od2:lhelpicon:=.f.
redefine get og[1] var vg[1] id 101 of od2 picture "@X" valid !empty(vg[1])
redefine get og[2] var vg[2] id 102 of od2 picture "@X" valid !empty(vg[2])
redefine get og[3] var vg[3] id 103 of od2 picture "@X" valid !empty(vg[3])
redefine checkbox ochk[1] var vchk[1] id 183 of od2 on CHANGE tstchk(ochk,vchk,1,vs)
redefine checkbox ochk[2] var vchk[2] id 184 of od2 on CHANGE tstchk(ochk,vchk,2,vs)
redefine checkbox ochk[3] var vchk[3] id 190 of od2 on CHANGE tstchk2(ochk,vchk,1,vs)
redefine checkbox ochk[4] var vchk[4] id 191 of od2 on CHANGE tstchk2(ochk,vchk,2,vs)
redefine checkbox ochk[5] var vchk[5] id 23 of od2 on CHANGE tstchk2(ochk,vchk,5,vs)
redefine say vs id 22 of od2
redefine say vsf[1] id 32 of od2
redefine say vsf[2] id 33 of od2
redefine say vsf[3] id 34 of od2
redefine say vsf[4] id 35 of od2
redefine get og[4] var vg[4] id 104 of od2 picture "@X"
redefine get og[5] var vg[5] id 105 of od2 picture "@X"
redefine get og[8] var vg[8] id 24 of od2 picture "@X"
redefine get og[9] var vg[9] id 25 of od2 picture "@X"
redefine get og[10] var vg[10] id 26 of od2 picture "@X"
redefine get og[11] var vg[11] id 27 of od2 picture "@X"
redefine button id 107 of od2 action faz:=.t.,od2:end()
redefine button id 108 of od2 action ol:=cgetdir("Escolha o local desejado",vg[5]),iif(!empty(ol),(vg[5]:=ol , og[5]:refresh()) , )
activate dialog od2 centered on init ( iif(elocal,(og[4]:hide(),vs:hide() ) , ) ,;
iif(!vchk[5],(vsf[1]:hide(),vsf[2]:hide(),vsf[3]:hide(),vsf[4]:hide(),og[8]:hide(),og[9]:hide(),og[10]:hide(),og[11]:hide() ) , (vsf[1]:show(),vsf[2]:show(),vsf[3]:show(),vsf[4]:show(),og[8]:show(),og[9]:show(),og[10]:show(),og[11]:show() ) ) )
if faz
if vchk[1]
oq:="LOCAL"
else
oq:="REMOTO"
endif
if vchk[3]
vg[6]:="1"
else
vg[6]:="2"
endif
if vchk[5]
vg[7]:="S"
else
vg[7]:="N"
endif
cCurDir := ( CurDrive()+":\"+CurDir()+"\" )
INI oIni FILE (ccurdir+"BACKUP.INI")
SET SECTION "CONECTION" ENTRY "UserName" TO encrypt(alltrim(vg[2])) OF oIni
SET SECTION "CONECTION" ENTRY "Password" TO encrypt(alltrim(vg[3])) OF oIni
SET SECTION "CONECTION" ENTRY "Tipo" TO oq OF oIni
SET SECTION "CONECTION" ENTRY "IP_SERV" TO vg[4] OF oIni
SET SECTION "CONECTION" ENTRY "BANC" TO alltrim(vg[1]) OF oIni
SET SECTION "CONECTION" ENTRY "caminho" TO alltrim(vg[5]) OF oIni
SET SECTION "CONECTION" ENTRY "tp_bk" TO vg[6] OF oIni
SET SECTION "CONECTION" ENTRY "atu_web" TO vg[7] OF oIni
SET SECTION "CONECTION" ENTRY "ip_web" TO vg[8] OF oIni
SET SECTION "CONECTION" ENTRY "banc_web" TO alltrim(vg[9]) OF oIni
SET SECTION "CONECTION" ENTRY "usu_web" TO alltrim(vg[10]) OF oIni
SET SECTION "CONECTION" ENTRY "senha_web" TO alltrim(vg[11]) OF oIni
ENDINI
endif
return nil
function tstchk(ochk,vchk,lugar,vs)
if lugar=1
if vchk[1]
vchk[2]:=.f.
ochk[2]:refresh()
else
vchk[2]:=.t.
ochk[2]:refresh()
endif
else
if vchk[2]
vchk[1]:=.f.
ochk[1]:refresh()
else
vchk[1]:=.t.
ochk[1]:refresh()
endif
endif
if vchk[1]
og[4]:hide()
vs:hide()
else
og[4]:show()
vs:show()
endif
return .t.
function tstchk2(ochk,vchk,lugar)
if lugar=1
if vchk[3]
vchk[4]:=.f.
ochk[4]:refresh()
else
vchk[4]:=.t.
ochk[4]:refresh()
endif
elseif lugar=2
if vchk[4]
vchk[3]:=.f.
ochk[3]:refresh()
else
vchk[3]:=.t.
ochk[3]:refresh()
endif
elseif lugar=5
if vchk[5]
* mostra os gets
og[8]:show()
og[9]:show()
og[10]:show()
og[11]:show()
vsf[1]:show()
vsf[2]:show()
vsf[3]:show()
vsf[4]:show()
else
* esconde os gets
og[8]:hide()
og[9]:hide()
og[10]:hide()
og[11]:hide()
vsf[1]:hide()
vsf[2]:hide()
vsf[3]:hide()
vsf[4]:hide()
endif
endif
return .t.
**********************
static function ativa_timer(liga)
**********************
ometer3:ctext:="MysqlDump trabalhando"
if liga
oTimerTime := TTimer():New( 200, { || incrementa() } )
oTimerTime:Activate()
else
oTimerTime:DeActivate()
ometer3:set(100)
endif
return NIL
static function incrementa()
namount3++
if namount3>100
namount3=0
endif
ometer3:set(namount3)
return nil
*************************
function DisableX( odlg )
*************************
local hMenu, nCount
#define MF_BYPOSITION 1024 // 0x0400
#define MF_DISABLED 0x00000002L
hMenu := GetSystemMenu( oDlg:hWnd, .F. )
RemoveMenu( hMenu, 1, MF_BYPOSITION )
return NIL
function pen_ok(cdrive)
local vol:=.t.,arq
if file(cdrive+"teste.txt")
ferase(cdrive+"teste.txt")
endif
arq:=fcreate(cdrive+"teste.txt",0)
n:=ferror()
if n<>0
vol:=.f.
endif
fclose(arq)
if file(cdrive+"teste.txt")
ferase(cdrive+"teste.txt")
endif
return vol
function qnome(tp_bk)
local vol,i1,i2,i3
if tp_bk="1"
* nome do arquivo de backup por data
* sempre cria 1 novo backup para cada dia, assim consome
* mais espaco fisico de armazenenamnto.
i1:=strzero(day(date()),2,0)
i2:=strzero(month(date()),2,0 )
i3:=substr(strzero(year(date()),4,0) ,3,2)
vol:="BK"+i1+i2+i3+".SQL"
else
* nome do backup por nome do dia
* sempre tera 7 arquivos de backup, segunda.sql, terca.sql, quarta.sql
* quinta.sql,_.sql,sabado.sql e domingo.sql
* Tendo somente estes 7 arquivos, o consumo de espaco de armazenagem
* e muito menor. A desvantagem e que somente tera backup dos ultimos sete
* dias de movimentacao.
i1=dow(date())
if i1=1
VOL:="DOMINGO.SQL"
elseif i1=2
VOL:="SEGUNDA.SQL"
elseif i1=3
VOL:="TERCA.SQL"
elseif i1=4
VOL:="QUARTA.SQL"
elseif i1=5
VOL:="QUINTA.SQL"
elseif i1=6
VOL:="_.SQL"
elseif i1=7
VOL:="SABADO.SQL"
endif
endif
return vol
function restore
local arq, listarq, otext
local odr,obr2,afile,adt,adf,edump
local aHBitMaps:= { ReadBitmap( 0, "checkoff.bmp" ), ; // BitMaps de 14 x 32
ReadBitmap( 0, "checkon.bmp" ) }
arq:=cgetfile("Arquivos de Backup |*.sql|","Selecione o Arquivo para Restaurar")
if empty(arq)
AEval( aHBitmaps, { | hBmp | DeleteObject( hBmp ) } )
return nil
endif
afile:=directory(arq)
adt:=afile[1,F_DATE]
adf:=afile[1,F_SIZE]
* cria arquivo dbf temporario na memoria
vldbf:= {}
AAdd(vldbf, {"tabela", "c", 50, 0})
AAdd(vldbf, {"sel_ok", "l",1 , 0})
select 77
Hb_DbCreateTemp("TRAB", vldbf)
Index on upper(tabela) Tag "01" To ("inut10") Memory
otext:=ttxtfile():new(arq)
edump:=.f.
if otext:open()
otext:gotop()
* verifica se o backup foi criado com o mysqldump
linha:=otext:readline()
tx:="-- MySQL dump"
if at(tx,linha)>=1 //encontrou
edump:=.t.
endif
if !edump
otext:close()
msgstop("Este Backup nÆo foi gerado pelo MysqlDump !","Erro")
AEval( aHBitmaps, { | hBmp | DeleteObject( hBmp ) } )
TRAB->(DBCLOSEAREA())
dbdrop("MEM:TRAB")
return nil
endif
do while !otext:leof()
linha:=otext:readline()
tx:="-- Table structure for table "
if at(tx,linha)>=1
linha:=strtran(linha,tx,"")
linha:=strtran(linha,"`","")
* if upper(substr(linha,1,3))<>"SR_"
append blank
replace tabela with linha
replace sel_ok with .t.
* endif
endif
otext:skip()
enddo
otext:close()
endif
go top
define dialog odr resource "restore" title oemtoansi("Restaura‡Æo de Backup")
odr:lhelpicon:=.f.
redefine listbox obr2 FIELDS iif (trab->sel_ok,aHBitmaps[ 2 ],aHBitmaps[ 1 ] ) ,;
trab->tabela ;
HEADERS " ",;
oemtoansi("Tabela");
COLOR CLR_BLACK,CLR_WHITE id 101 of odr
* ON DBLCLICK (iif(reglock(10),(trab->sel_ok:=iif(trab->sel_ok,.f.,.t.),dbunlock() ), ) ,obr2:refresh() ) UPDATE
* obr2:bKeyChar := {|nK| if( nK==VK_RETURN, (iif(reglock(10),(trab->sel_ok:=iif(trab->sel_ok,.f.,.t.),dbunlock() ), ) ,obr2:refresh() ) ,NIL)}
redefine say id 30 of odr prompt arq color CLR_BLACK,CLR_WHITE
redefine say id 31 of odr prompt adt color CLR_BLACK,CLR_WHITE
redefine say id 32 of odr prompt transform(adf,"@E 999,999,999,999" ) color CLR_BLACK,CLR_WHITE
redefine button id 50 of odr action rest_tudo(arq)
redefine button id 52 of odr action odr:end()
activate dialog odr centered
AEval( aHBitmaps, { | hBmp | DeleteObject( hBmp ) } )
TRAB->(DBCLOSEAREA())
dbdrop("MEM:TRAB")
return nil
* funcao que trava o registro na rede
function reglock(p1)
local Local1
if p1=NIL
p1:= 5
endif
do while (.T.)
for Local1:= 1 to p1
if (RLock())
return .T.
endif
InKey(0.5)
next
if !msgyesno("Registro Bloqueado! Tenta novamente ?")
return .F.
endif
enddo
RETURN( .F. )
function rest_tudo(arq)
local od8,ogru,ob1,ob2
private oMeter3,nAmount3:=0
define dialog od8 resource "rest_tudo" title oemtoansi("Restaurar Tudo")
od8:lhelpicon:=.f.
redefine group ogru id 26 of od8 color CLR_BLACK,CLR_WHITE
redefine say id 40 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 41 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 42 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 43 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 44 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 45 of od8 color CLR_BLACK,CLR_WHITE group ogru
redefine say id 141 of od8 prompt arq color CLR_BLACK
REDEFINE METER oMeter3 VAR nAmount3 ID 130 OF oD8
ometer3:lpercentage:=.f.
redefine button ob1 id 25 of od8 action restatud(od8,ob1,ob2,arq),od8:end()
redefine button ob2 id 50 of od8 action od8:end()
activate dialog od8 centered
return nil
function restatud(od8,ob1,ob2,arq)
local outd,cComando,user,senh,tp,ip,banc,cami,tp_bk,tfim
cCurDir := ( CurDrive()+":\"+CurDir()+"\" )
if file(cCurDir+"BACKUP.INI")
* le do ini
INI oIni FILE (ccurdir+"BACKUP.INI")
GET user SECTION "CONECTION" ENTRY "UserName" OF oIni
GET senh SECTION "CONECTION" ENTRY "Password" OF oIni
GET tp SECTION "CONECTION" ENTRY "Tipo" OF oIni
GET ip SECTION "CONECTION" ENTRY "IP_SERV" OF oIni
GET banc SECTION "CONECTION" ENTRY "BANC" OF oIni
GET cami SECTION "CONECTION" ENTRY "caminho" OF oIni
GET tp_bk SECTION "CONECTION" ENTRY "tp_bk" OF oIni
ENDINI
user:=substr(decrypt(alltrim(user))+space(50),1,50)
senh:=substr(alltrim(decrypt(senh))+space(50),1,50)
ip :=substr(alltrim(ip)+space(19),1,19)
banc:=substr(alltrim(banc)+space(50),1,50)
* pega nome do arquivo de backup
nombkp:=arq
if tp="LOCAL"
* cComando:='mysqldump.exe --opt -u '+user +' -p'+ senh + ' '+banc +' < '+nombkp+' '+CRLF
cComando:='mysql.exe -u '+user+' -p'+ senh +' -h localhost '+banc+' < '+nombkp+' '+CRLF
else
* cComando:='mysqldump.exe --opt -h '+ ip +' -u '+ user +' -p'+senh +' '+banc+ ' < '+nombkp+' '+CRLF
cComando:='mysql.exe -u '+user+' -p'+ senh +' -h '+ ip +' '+banc+' < '+nombkp+' '+CRLF
endif
else
msgstop(oemtoansi("Arquivo de Configura‡Æo nÆo encontrado !"),"Erro")
return nil
endif
disablex(od8)
ob1:disable()
ob2:disable()
* faz o restore
oudt:=time()
ativa_timer(.t.)
oMeter3:nTotal = 100
* roda o mysqldump
myrun(cComando)
ativa_timer(.f.)
ob1:enable()
ob2:enable()
tfim:=time()
msgalert( oemtoansi('Restaura‡Æo Completada Com Sucesso !')+CRLF+CRLF+ ;
"Tempo Total gasto: "+elaptime( oudt , tfim ) ,'Aviso' )
return .t.
#define DIALOG_4 4
#define DIALOG_1 1
#define DIALOG_3 3
#define DIALOG_2 2
main DIALOG 53, 92, 359, 189
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Copiar arquivo de atualizacao"
FONT 8, "MS Sans Serif"
{
CONTROL "TBitMap", 350, "TBitMap", WS_CHILD | WS_VISIBLE, 1, 32, 117, 158
PUSHBUTTON "1- Gerar Backup do Sistema", 21, 142, 7, 196, 22
PUSHBUTTON "2- Restaurar Backup", 22, 142, 42, 196, 22
PUSHBUTTON "3- Configurações do Backup", 23, 142, 77, 196, 22, BS_LEFTTEXT | WS_TABSTOP
PUSHBUTTON "4- Sair", 24, 142, 127, 196, 22, BS_LEFTTEXT | WS_TABSTOP
CONTROL "TBitMap", 351, "TBitMap", WS_CHILD | WS_VISIBLE, 1, 2, 117, 30
}
config DIALOG 80, 69, 405, 232
STYLE 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Copiar arquivo de atualizacao"
FONT 8, "MS Sans Serif"
{
EDITTEXT 101, 86, 8, 232, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 102, 86, 26, 232, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 103, 86, 44, 232, 15, ES_PASSWORD | WS_BORDER | WS_TABSTOP
AUTOCHECKBOX "Banco de Dados Local", 183, 19, 67, 92, 12
AUTOCHECKBOX "Banco de Dados Remoto", 184, 115, 67, 97, 12
EDITTEXT 104, 263, 66, 122, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 105, 12, 95, 295, 15, WS_BORDER | WS_TABSTOP
PUSHBUTTON "&Gravar", 107, 168, 208, 68, 17
PUSHBUTTON "Procurar", 108, 311, 95, 36, 15
LTEXT "Banco de Dados:", -1, 17, 10, 65, 11
LTEXT "Usuário:", -1, 17, 28, 65, 11
LTEXT "Senha:", -1, 17, 47, 65, 11
LTEXT "IP Servidor:", 22, 222, 69, 39, 11
LTEXT "Local a ser gravado o backup ", -1, 12, 84, 227, 8
AUTOCHECKBOX "Nome do Backup por data. Exemplo: BK040112.SQL , BK311211.SQL, etc...", 190, 11, 116, 344, 12
AUTOCHECKBOX "Nome do Backup por nome do dia. Exemplo: SEGUNDA.SQL, TERCA.SQL, QUARTA.SQL, etc...", 191, 11, 130, 345, 12
AUTOCHECKBOX "Transmitir Banco de Dados para a Internet", 23, 108, 150, 153, 12
EDITTEXT 24, 79, 165, 122, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 25, 281, 165, 96, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 26, 79, 183, 122, 15, WS_BORDER | WS_TABSTOP
EDITTEXT 27, 281, 183, 96, 15, WS_BORDER | WS_TABSTOP
LTEXT "IP Servidor Internet:", 32, 9, 168, 66, 11
LTEXT "USUÁRIO:", 34, 9, 186, 66, 11
LTEXT "Banco de Dados:", 33, 219, 168, 59, 11
LTEXT "SENHA:", 35, 219, 186, 59, 11
}
protect2 DIALOG 195, 63, 156, 203
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
{
LTEXT "Local a ser Gravado o Backup:", 182, 2, 3, 152, 12
PUSHBUTTON "&Sair", 50, 94, 181, 50, 17
PUSHBUTTON "&Iniciar Backup", 25, 12, 181, 76, 17
LTEXT "Origem:", 110, 6, 95, 144, 8
LTEXT "Destino:", 120, 7, 110, 146, 8
CONTROL "", 130, "TMeter", WS_CHILD | WS_VISIBLE, 5, 123, 147, 11
LTEXT "Bytes copiados:", 140, 6, 141, 147, 8
CONTROL "", 150, "TMeter", WS_CHILD | WS_VISIBLE, 5, 151, 147, 11
CONTROL "TMeter", 151, "TMeter", WS_CHILD | WS_VISIBLE, 5, 70, 147, 14
LTEXT "", 141, 7, 60, 144, 8
EDITTEXT 26, 1, 14, 153, 16, WS_BORDER | WS_TABSTOP
PUSHBUTTON "&Alterar Local", 27, 87, 33, 66, 17
}
restore DIALOG 237, 64, 276, 234
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
{
PUSHBUTTON "&Restaurar Tudo", 50, 148, 70, 117, 21
PUSHBUTTON "&Sair", 52, 148, 112, 117, 21
CONTROL "", 101, "TWBrowse", WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 8, 70, 115, 156
LTEXT "Arquivo de Backup:", -1, 6, 10, 65, 10
LTEXT "Data de Criação:", -1, 6, 26, 65, 10
LTEXT "Tamanho (Bytes):", -1, 142, 26, 58, 10
LTEXT "Text", 30, 76, 9, 193, 12, WS_BORDER | WS_GROUP
LTEXT "Text", 31, 76, 26, 49, 12, WS_BORDER | WS_GROUP
LTEXT "Text", 32, 202, 26, 67, 12, WS_BORDER | WS_GROUP
LTEXT "Tabelas encontradas no backup", -1, 10, 58, 123, 8
}
rest_tudo DIALOG 195, 63, 156, 203
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
{
GROUPBOX "", 26, 2, -3, 151, 112, BS_GROUPBOX
CTEXT "ATENÇÃO", 40, 8, 8, 140, 13
CTEXT "Tem certeza que deseja restaurar", 41, 8, 27, 140, 13
CTEXT "todos os arquivos do Backup ?", 42, 8, 40, 140, 13
CTEXT "Todas a informações atuais serão", 43, 8, 60, 140, 13
CTEXT "substituídas pelas informações", 44, 8, 73, 140, 13
CTEXT "contidas no backup.", 45, 8, 86, 140, 13
LTEXT "", 141, 7, 112, 144, 8
CONTROL "TMeter", 130, "TMeter", WS_CHILD | WS_VISIBLE, 5, 122, 147, 14
PUSHBUTTON "&Iniciar Restauração", 25, 12, 181, 76, 17
PUSHBUTTON "&Sair", 50, 94, 181, 50, 17
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 95 guests