Backup & Restore Dbf Files

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
mol
Posts: 3250
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 233 times
Been thanked: 132 times
Contact:

Re: Backup & Restore Dbf Files

Post by mol » Wed Mar 28, 2012 12:58 pm

Problem lays in these lines:

Code: Select all

aTemp := DIRECTORY( BackUp.T_SourceFolder.Value + "\*.*" )
   
   AEVAL( aTemp, { | a1 | AADD( aFilesToBackup, a1[ 1 ] ) } )
   
   IF EMPTY( aFilesToBackup )
      MsgStop( "No file found to backup !", " ERROR !" )    
   ELSE
      BackUp.ProgressIndicator.RangeMax := len(aFilesToBackup)
      BackUp.ProgressIndicator.Value := 0

      COMPRESS aFilesToBackup ;
         TO cArchiveName ;
         BLOCK {|cFile,nPos|  BackUp.ProgressIndicator.Value := nPos }  ;
         OVERWRITE
	
      lBackupStatus  := .t.
      msgbox("Backup created successful!") 
They should be:

Code: Select all

  aTemp := DIRECTORY( BackUp.T_SourceFolder.Value + "\*.*" )
   
   AEVAL( aTemp, { | a1 | AADD( aFilesToBackup, BackUp.T_SourceFolder.Value + "\"+ a1[ 1 ] ) } )
   
   IF EMPTY( aFilesToBackup )
      MsgStop( "No file found to backup !", " ERROR !" )    
   ELSE
      BackUp.ProgressIndicator.RangeMax := len(aFilesToBackup)
      BackUp.ProgressIndicator.Value := 0

      COMPRESS aFilesToBackup ;
         TO cArchiveName ;
         BLOCK {|cFile,nPos|  BackUp.ProgressIndicator.Value := nPos }  ;
         OVERWRITE
	
      lBackupStatus  := .t.
      msgbox("Backup created successful!") 
Another way is to change current dir to folder being compressed.

The problem is, that version does not compress subdirectories of selected location :(

User avatar
esgici
Posts: 4518
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 391 times
Been thanked: 111 times
Contact:

Post by esgici » Thu Mar 29, 2012 11:50 am

Hi all

Please forgive me for disturbing :(

Found source of error: it's my fault :(

Our COMPRESS command doesn't have any problem :)

Again, sorry for false report :(

Best regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Thu Mar 29, 2012 1:24 pm

No problem Esgici. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
mol
Posts: 3250
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 233 times
Been thanked: 132 times
Contact:

Post by mol » Thu Mar 29, 2012 2:17 pm

Didn't you try to build archiving with subdirectories?
Marek

User avatar
esgici
Posts: 4518
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 391 times
Been thanked: 111 times
Contact:

Post by esgici » Thu Mar 29, 2012 2:37 pm

Hi Mol
mol wrote:Didn't you try to build archiving with subdirectories?
Marek
I am working on it (with others).

I gues it's possible, but require a little extra effort; such as recursion.

And I guess also, if <aFiles> include path info together file names, COMPRESS store its in the result (.zip) file.

But sadly, Windows doesn't show content of such (including path infos) archive files :(

If I will reach a acceptable result, I will inform you.

Regards.

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
danielmaximiliano
Posts: 2167
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 178 times
Been thanked: 26 times
Contact:

Post by danielmaximiliano » Tue Apr 03, 2012 7:50 pm

Hola muchachos:
perdon por hacer esta pregunta tonta.
modificando Zipdemo de HMG3.0.40
C:\hmg.3.0.40\SAMPLES\ZIP
los pasos se hacen correctamente, pero al abrir el archivo compactado me encuentro que esta vacio..
utilizando el depurador veo que toma el contenido de la carpeta en cuestion.

uso este ejemplo ya que tengo algo parecido para el respaldo de mi aplicacion y me hace lo mismo.
donde fallo ????

/****************** Translate Google *************************/
*********************************************************
Hi guys:
sorry for asking this silly question.
modifying Zipdemo of HMG3.0.40
C:\hmg.3.0.40\SAMPLES\ZIP
steps are done correctly, but when you open the zip file is empty I find that ..
using the debugger I see that takes the contents of the folder in question.

use this example because I have something similar to the support of my application and I do the same.
where failure ?????

Code: Select all

#include "hmg.ch"

Function main()
	DEFINE WINDOW form_1 ; 
		AT 114,218 ;
		WIDTH 334 ;
		HEIGHT 276 ; 
		TITLE 'ZIP TEST' ; 
		MAIN 

		DEFINE MAIN MENU

			DEFINE POPUP "Test"
				MENUITEM 'Create Zip' ACTION CreateZip()
			END POPUP

		END MENU

		@ 80,120 PROGRESSBAR Progress_1 RANGE 0,10 SMOOTH

		@ 120,120 LABEL label_1 VALUE ''


	END WINDOW 

	form_1.center
	form_1.activate

Return NIL

*------------------------------------------------------------------------------*
Function CreateZip()
*------------------------------------------------------------------------------*
local aDir:=Directory("Text\*.txt")
local afiles:={}
Local x
local nLen

	For x:=1 to len(aDir)
	    aadd(afiles,adir[x,1])
	next

	COMPRESS afiles ;
		TO 'c:\ZipTest.Zip' ;
		BLOCK {|cFile,nPos| ProgressUpdate( nPos , cFile ) }  ;
		OVERWRITE

Return nil

*------------------------------------------------------------------------------*
function ProgressUpdate(nPos , cFile )
*------------------------------------------------------------------------------*

	Form_1.Progress_1.Value := nPos
	Form_1.Label_1.Value := cFile

Return Nil
CZIPzipdemo.png
CZIPzipdemo.png (87.59 KiB) Viewed 3291 times
Text_2012-04-03_16-32-02.png
Text_2012-04-03_16-32-02.png (141.41 KiB) Viewed 3291 times
ZipTest.png
ZipTest.png (64.63 KiB) Viewed 3291 times
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
esgici
Posts: 4518
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 391 times
Been thanked: 111 times
Contact:

Post by esgici » Tue Apr 03, 2012 8:05 pm

aadd(afiles,"text\"+adir[x,1]) // Line 40
Viva INTERNATIONAL HMG :D

paimar
Posts: 64
Joined: Wed May 23, 2012 8:52 pm

Post by paimar » Thu Jul 05, 2012 10:04 pm

First off all sorry for my horrible english.

If there is not a "clean" solution for making a backup of subdirectories I'm thinking in a very "dirty" solution :)

May be go throgh all directories and copy the files I need to one only directory. For the restore do the opposite.


Ahggg que alivio escribir en español :) Si no hay una solucion mas limpia para el tema de hacer backups de directorios con subdirectorios estoy pensando
en ir por los subdirectorios y copiar todos los archivos a un unico directorio y luego comprimir este. Para el restore se haria a la inversa copiando segun el tipo
de archivo a su directorio Dbf's a directorio dbf jpg's a directorio jpg etc.

Seria posible no?

un saludo
Gipuzkoa - ESPAÑA

User avatar
IMATECH
Posts: 174
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.
Has thanked: 1 time
Been thanked: 3 times

Post by IMATECH » Thu Jul 05, 2012 10:21 pm

I think it's not a "clean" solution: But Works Well :)

Code: Select all


  LOCAL sCMD := 'WINRAR.EXE a -v -r BK_' + DTOS( DATE() ) + ' *.DB? *.JPG'
  HB_RUN( sCMD )



IF you have time... then can use a Better solution using "HB_DirScan(...)"

See the sample at:
\Harbour\contrib\hbmzip\tests\myzip.prg
\Harbour\contrib\hbmzip\tests\myunzip.prg

Code: Select all


PROCEDURE Main( ... )
   LOCAL hZip, aDir, aFile, aWild, ;
         cZipName, cPath, cFileName, cExt, cWild, cPassword, cComment,;
         tmp

   aWild := { ... }
   IF LEN(aWild) < 2
      ? "Usage: myzip <ZipName> [ --pass <password> ] [ --comment <comment> ] <FilePattern1> [ <FilePattern2> ... ]"
      RETURN
   ENDIF

   HB_FNameSplit( aWild[ 1 ], @cPath, @cFileName, @cExt )
   IF EMPTY( cExt )
      cExt := ".zip"
   ENDIF
   cZipName := HB_FNameMerge( cPath, cFileName, cExt )

   HB_ADEL( aWild, 1, .T. )

   FOR tmp := LEN( aWild ) - 1 TO 1 STEP -1
      IF LOWER( aWild[ tmp ] ) == "--pass"
         IF EMPTY( cPassword )
            cPassword := aWild[ tmp + 1 ]
         ENDIF
         aWild[ tmp ] := ""
         aWild[ tmp + 1 ] := ""
      ELSEIF LOWER( aWild[ tmp ] ) == "--comment"
         IF EMPTY( cComment )
            cComment := aWild[ tmp + 1 ]
         ENDIF
         aWild[ tmp ] := ""
         aWild[ tmp + 1 ] := ""
      ENDIF
   NEXT

   hZip := HB_ZIPOPEN( cZipName )
   IF ! EMPTY( hZip )
      ? "Archive file:", cZipName
      FOR EACH cWild IN aWild
         IF !EMPTY( cWild )
            HB_FNameSplit( cWild, @cPath, @cFileName, @cExt )
            aDir := HB_DirScan( cPath, cFileName + cExt )
            FOR EACH aFile IN aDir
               IF ! cPath + aFile[ 1 ] == cZipName
                  ? "Adding", cPath + aFile[ 1 ]
                  HB_ZipStoreFile( hZip, cPath + aFile[ 1 ], cPath + aFile[ 1 ], cPassword )
               ENDIF
            NEXT
         ENDIF
      NEXT
      HB_ZIPCLOSE( hZip, cComment )
   ENDIF

RETURN

M., Ronaldo

By: IMATECH

Imation Tecnologia

User avatar
AidTIC
Posts: 93
Joined: Mon Apr 22, 2013 8:29 am
DBs Used: DBF
Been thanked: 3 times
Contact:

Post by AidTIC » Wed Jul 17, 2013 9:17 am

perdon, a ver si me podeis ayudar.

He retocado el programa que viene con HMG.3.0.46 de Zip. Para que me comprima 2 DBF que tengo en un subdirectorio.

Y me crea el .zip perfectamente. pero no consigo que termine el programa. se queda asi:

Image

El boton de Aceptar siempre esta activo.
Donde esta fallando?

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#include "hmg.ch"

Function main()

DEFINE WINDOW form_1 ;
AT 114,218 ;
WIDTH 334 ;
HEIGHT 276 ;
TITLE 'ZIP TEST' ;
MAIN

DEFINE MAIN MENU

DEFINE POPUP "Test"
MENUITEM 'Create Zip' ACTION CreateZip()
END POPUP

END MENU

@ 80,120 PROGRESSBAR Progress_1 RANGE 0,10 SMOOTH

@ 120,120 LABEL label_1 VALUE ''

DEFINE BUTTON Boton_Ac
ROW 170
COL 100
WIDTH 150
HEIGHT 48
CAPTION ' Aceptar '
FONTNAME "Arial"
FONTSIZE 18
FONTBOLD .T.
ONCLICK form_1.Release // Iif (MsgOkCancel ("Desea Enviar Los Ficheros?", "Envio de Ficheros") , MainCreateZip() , Win_ENLA.Release)
HELPID "Aceptar"
VISIBLE .T.
END BUTTON



END WINDOW

form_1.center
form_1.activate
form_1.Boton_Ac.Enabled := .f.

Return NIL

*------------------------------------------------------------------------------*
Function CreateZip()
*------------------------------------------------------------------------------*
local aDir:=Directory("Enlace\*.DBF")
local afiles:={}
Local x
local nLen

For x:=1 to len(aDir)
aadd(afiles,"Enlace\"+adir[x,1])
next

COMPRESS afiles ;
TO 'ZipTest.Zip' ;
BLOCK {|cFile,nPos| ProgressUpdate( nPos , cFile ) } ;
OVERWRITE


form_1.Boton_Ac.Enabled := .T.
Return nil

*------------------------------------------------------------------------------*
function ProgressUpdate(nPos , cFile )
*------------------------------------------------------------------------------*

Form_1.Progress_1.Value := nPos
Form_1.Label_1.Value := cFile

Return Nil
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Attachments
pantalla.jpg
pantalla.jpg (50.71 KiB) Viewed 2103 times
Skydone Solutions
www.skydone.com

Post Reply