simple backup program

HMG Samples and Enhancements

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

simple backup program

Post 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
Attachments
backup.zip
(2.84 KiB) Downloaded 535 times
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: simple backup program

Post by jairpinho »

Very good your program if I can translate English to use it for backups
Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: simple backup program

Post by Rathinagiri »

Very useful Marek. If it can be attached to IDE, that will be more helpful.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: simple backup program

Post by mol »

very nice idea Rathi! It could be wonderful to automatically create backup of source files while closing IDE.
User avatar
danielmaximiliano
Posts: 2611
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: simple backup program

Post 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 6206 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.
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: simple backup program

Post 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
Attachments
backup.zip
(3.06 KiB) Downloaded 446 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: simple backup program

Post 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,
Attachments
backup.rar
(1.34 KiB) Downloaded 419 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: simple backup program

Post by esgici »

Thanks Marek,

Nice utility :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
fchirico
Posts: 324
Joined: Sat Aug 23, 2008 11:27 pm
Location: Argentina

Re: simple backup program

Post by fchirico »

Thanks for sharing!!!

Very usefull.
Saludos, Fernando Chirico.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: simple backup program

Post 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
Viva INTERNATIONAL HMG :D
Post Reply