Page 1 of 2

simple backup program

Posted: Mon Mar 19, 2012 4:24 pm
by mol
Hi guys!
Do you remember this time, when you lost you've changed your code, saved changes and made a copy rewriting your archive, then understood mistake???

I had it today...

But, for happiness, I had a copy on third computer :)

So, I've decided to write small application, quick to run, to archive my *.prg and *.fmg files to archive named by timestamp.

All names are in Polish, I can translate it to English when somebody will be interested of.
The code is clearly written, I hope ;)
Nice testing!
Regards, Marek

Re: simple backup program

Posted: Mon Mar 19, 2012 4:32 pm
by jairpinho
Very good your program if I can translate English to use it for backups

Re: simple backup program

Posted: Mon Mar 19, 2012 4:47 pm
by Rathinagiri
Very useful Marek. If it can be attached to IDE, that will be more helpful.

Re: simple backup program

Posted: Mon Mar 19, 2012 5:47 pm
by mol
very nice idea Rathi! It could be wonderful to automatically create backup of source files while closing IDE.

Re: simple backup program

Posted: Mon Mar 19, 2012 6:21 pm
by danielmaximiliano
Hi Mol:
appreciate your contribution.
in my case I use the backup of Crimson Editor.
is also incremental.
Greenshot_2012-03-19_15-16-51.png
Greenshot_2012-03-19_15-16-51.png (201.74 KiB) Viewed 6573 times
also open the FMG, so when I change the FMG with the IDE takes modificacions Crimson editor and writes well in an incremental manner.

Re: simple backup program

Posted: Mon Mar 19, 2012 7:16 pm
by mol
I've translated this sample to English. I've made some changes in code, too.

Write your opinions if you like/dislike it :)

Best regards, Marek

Re: simple backup program

Posted: Mon Mar 19, 2012 8:00 pm
by Pablo César
Very nice example Mr. Marek and wonderfull idea of Mr. Rathi!

I was translating screen and I noted you have already done, that it is very good. But you please if you want consider this my last translation, please use attached file.

Thank you for your sharing !

Best regards,

Re: simple backup program

Posted: Mon Mar 19, 2012 8:06 pm
by esgici
Thanks Marek,

Nice utility :)

Regards

--

Esgici

Re: simple backup program

Posted: Tue Mar 20, 2012 1:36 am
by fchirico
Thanks for sharing!!!

Very usefull.

Re: simple backup program

Posted: Tue Mar 20, 2012 7:32 pm
by esgici
Hi

A few suggestions :

For function main() :

Code: Select all

   PRIVATE cFileKinds_FNam    := "FilKinds.lst",;   // File kinds file name
           cFileKinds         := "",;               // File kinds string
           aFileKinds         := {}                 // File kinds array
           
   IF FILE( cFileKinds_FNam )
      cFileKinds := MEMOREAD( cFileKinds_FNam)              // File kinds string
      IF !EMPTY( cFileKinds ) 
         aFileKinds := HB_ATOKENS( cFileKinds, CRLF )
      ENDIF
   ENDIF
   
   IF EMPTY( aFileKinds )
      aFileKinds := { "PRG", "FMG" }
   ENDIF
   
   AEVAL( aFileKinds, { | c1, i1 | aFileKinds[ i1 ] := "*." + c1 } )

For function MakeBackup() :

Code: Select all

	BackUp.ProgressIndicator.Visible := .t.

/*   
from clipper docs :

   ADIR() is a compatibility function and therefore not recommended.  It is
   superseded by the DIRECTORY() function which returns all file
   information in a multidimensional array.
   
moreover ...

   ADIR() require calling twice :( 
   
*/ 
   
   FOR EACH cFileKind IN aFileKinds 
      aTemp := DIRECTORY( cFileKind )
      AEVAL( aTemp, { | a1 | AADD( aFilesToBackup, a1[ 1 ] ) } )
   NEXT
   
   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
		
      // You can save backub settings here
      //SaveBackupConfiguration()
	
      lBackupStatus  := .t.
      msgbox("Backup created successful!") 
   ENDIF   
	BackUp.Release
return
*-------------------
Content of my FilKinds.lst :
ch
prg
fmg
hbp
hbc
log
lst
For all files, a single "*" is sufficient ;)

I wish you will like it :)

Regards

--

Esgici