Buenas tardes compa帽eros,
Me gustar铆a poder realizar copias de seguridad de mi sistema en la nube. Muchas gracias de antemano!
Buenas tardes compa帽eros,
Me gustar铆a poder realizar copias de seguridad de mi sistema en la nube. Muchas gracias de antemano!
*********************************
//REALIZA LA COPIA DE SEGURIDAD
*********************************
Function copiaseguridad()
local oCn
Local cRutaSql := ".\copias\"
Local cNombSql := 聽 alltrim(oLamcla:vGnit) + "_" + DTOS(DATE()) + "_" + SUBSTR(TIME(),1,2) +;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 SUBSTR(TIME(),4,2) + SUBSTR(TIME(),7,2) + ".Sql"
Local cRutFina := cRutaSql+cNombSql
Local documento := {=>}
Local cbCopia := <||
聽 聽 聽 聽 verificaTablasCopias(oCnEmp)
聽 聽 聽 聽
聽 聽 聽 聽 //ACTUALIZAMOS LA FECHA DE LA ULTIMA COPIA EN LA BASE DE DATOS
聽 聽 聽 聽 oSlq:= TCad():New(oLamcla:tEmpr,oCnEmp)
聽 聽 聽 聽 oSlq:Campos("e_ultima_copia",dtos(date()))
聽 聽 聽 聽 oSlq:Condicion("e_codi",oLamcla:vGcod,"")
聽 聽 聽 聽 oSlq:Actualiza()
聽 聽 聽 聽 oSlq:=nil聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 //LEEMOS EL ARCHIVO PLANO PARA ENVIARLO AL SERVIDOR
聽 聽 聽 聽 cText := MemoRead( cRutFina )
聽 聽 聽 聽 //ENVIAMOS LA COPIA DE SEGURIDAD AL SERVIDOR
聽 聽 聽 聽 tercero := alltrim(oLamcla:vGnit)
聽 聽 聽 聽 pass := "TuClave" 聽 //TEMPORAL
聽 聽 聽 聽 cBas64 := hb_base64encode(tercero+":"+pass,len(tercero+":"+pass))
聽 聽 聽 聽 //DATOS PARA REGISTRO EN LA BASE DE DATOS
聽 聽 聽 聽 documento["tercero"] := tercero
聽 聽 聽 聽 documento["nombre_sql"] := cNombSql
聽 聽 聽 聽 documento["sql"] := cText
聽 聽 聽 聽 documento["sucursal"] := oLamcla:nEmpSucu
聽 聽 聽 聽 enviar := hb_jsonEncode( documento )
聽 聽 聽 聽 ohttp := CreateObject( "MSXML2.XMLHTTP" )
聽 聽 聽 聽 ohttp:Open( "POST" ,"http://tudominio.com/dondeguardamos",.F.)
聽 聽 聽 聽 oHttp:SetRequestHeader("cache-control", "no-cache")
聽 聽 聽 聽 ohttp:SetRequestHeader("content-type", "application/json" )
聽 聽 聽 聽 ohttp:SetRequestHeader("authorization", "Basic "+cBas64 )
聽 聽 聽 聽 TRY
聽 聽 聽 聽 聽 ohttp:Send( enviar )
聽 聽 聽 聽 CATCH
聽 聽 聽 聽 聽 聽 msginfo("No Se Pudo Enviar Archivo ","Intente Nuevamente")
聽 聽 聽 聽 聽 聽 return .t.
聽 聽 聽 聽 END
聽 聽 聽 聽 response:=ohttp:responseText
聽 聽 聽 聽 aHasRes := hash()
聽 聽 聽 聽 hb_jsondecode(response ,@aHasRes)
聽 聽 聽 聽 if aHasRes["copia_confirma"]
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 //ACTUALIZAMOS LA FECHA DE LA ULTIMA COPIA EN LA BASE DE DATOS
聽 聽 聽 聽 聽 聽 oSlq:= TCad():New(oLamcla:tEmpr,oCnEmp)
聽 聽 聽 聽 聽 聽 oSlq:Campos("e_ultima_nube",dtos(date()))
聽 聽 聽 聽 聽 聽 oSlq:Condicion("e_codi",oLamcla:vGcod,"")
聽 聽 聽 聽 聽 聽 oSlq:Actualiza()
聽 聽 聽 聽 聽 聽 oSlq:=nil聽 聽聽 聽 聽 聽
聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 MsgInfo("Proceso Completado Correctamente - Archivo Guardado "+cRutFina,"Confirma")
聽 聽 聽 聽 else
聽 聽 聽 聽 聽 聽 MsgInfo("Proceso NO pudo ser completado ","Error Datos")
聽 聽 聽 聽 endif
聽 聽 >
oCn := maria_Connect( alltrim(oLamcla:cHost),alltrim(oLamcla:cEmpDBda),alltrim(oLamcla:cUsuario),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 alltrim(oLamcla:cPassword) )
if oCn == nil
聽 聽 msginfo(聽 聽 "No se pudo comprobar la conexi贸n con la base de datos"+CRLF+;
聽 聽 聽 聽 聽 聽 "Por favor revise la ip en la configuraci贸n de la conexi贸n","Error Conexi贸n")
else
聽 聽 MYSQL_CRYPTKEY( alltrim(oLamcla:cPassword) )
聽 聽 oCn:BackUp( nil , cRutFina )
聽 聽 MYSQL_CRYPTKEY( nil )
聽 聽 oCn:close()
聽 聽
聽 聽 MsgRun("Procesando Informaci贸n...","Creando Archivo",{||CursorWait(),WaitRun(eval(cbCopia), 0 )})
聽 聽
endif
Return nilMil gracias. Lo voy a probar.
Estimado Leandro,
muchas gracias por compartirlo