Page 2 of 3

Re: Programa para BACKUP

Posted: Thu Feb 25, 2016 10:34 am
by mol
I'm using my own function to backup files. I'm putting here listing. I translated names of variables, if you find any error, please send a comment.
(This function uses sys2.dbf which contains definitions of .dbf files, in this case I use it as a list of files to archive)

Code: Select all

function MakeBackup
	param cArchiveFolder, cArchiveName
	
	local CFileName
	local cComment, cPassword
	static lPendingArchivization := .f.
	

	if lPendingArchivization
		return
	endif
	
	lPendingArchivization := .t.
	cPassword := 'you can give your password to zip file here'
	cComment := "Archive from day: " + dtoc(date())+" "+time() +;
		chr(13)+chr(10)+;
		"Company: Your company name" +;
		chr(13)+chr(10)+;
		"Program FAKTURY (MOL-SK Marek Olszewski)"+;
		chr(13)+chr(10)+;
		"Version: "+ cApplicationVersion 
		
	if substr(cArchiveFolder,-1) <> "\"
		cArchiveFolder += "\"
	endif
	
	if !file(cArchiveFolder+"nul")
		CreateFolder(cArchiveFolder)
		if !file(cArchiveFolder+"\nul")
			MsgStop("Cannot create archive folder. Stopped!!!")
			lPendingArchivization := .f.
			return
		endif
	endif
		
	cArchiveName := cArchiveFolder + cArchiveName + ".zip"
	
	if file(cArchiveName)
		if !MsgYesNo("Archive File already exists. Overwrite?","Overwrite archive file?",.t.)
			lPendingArchivization := .f.
			return
		endif
	endif
	
	// database sys2 contains list of all .dbf files to archive
	Use sys2 new
	
	sys2->(DBGoTop())
	
	hZip :=  HB_ZIPOPEN( cArchiveName )
	if ! empty( hZip )
		do while !sys2->(eof())
			CFileName := alltrim(sys2->FileName)
			if ascan(CFileName, ".") = 0
				// filename does not contain extension
				CFileName += ".dbf"
			endif
			HB_ZipStoreFile( hZip, cFileName, cFileName, cPassword )
			sys2->(DBSkip())
		enddo
		sys2->(DBCloseArea())
		HB_ZIPCLOSE( hZip, cComment )
	endif
	lPendingArchivization := .f.
return

Re: Programa para BACKUP

Posted: Thu Feb 25, 2016 3:17 pm
by danielmaximiliano

Re: Programa para BACKUP

Posted: Thu Feb 25, 2016 9:18 pm
by JALMAG
Hola Daniel, los ejemplos son de Notepad...no de Backup.
Saludos

Re: Programa para BACKUP

Posted: Fri Feb 26, 2016 9:20 pm
by Steed
Hi,

Use HMG_MYSYNC is made whit HMG
HMG_MYSYNC.rar
(1.22 MiB) Downloaded 363 times
Regards,

ES

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 8:52 am
by bpd2000
+1

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 9:01 am
by serge_girard
Thanks for sharing John Steed!

Serge

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 1:03 pm
by Roberto Lopez
I'm using a combination of three things:

1. "System Scheduler" (http://www.splinterware.com/products/wincron.htm): It allows schedule the backups at specified times. It is wonderful and has a free version that does all required things.

2. "7-zip" (http://www.7-zip.org/): It is the most efficient compressor out there and it is FREE.

3. MOVEit Freely FTP Client (http://www.ipswitchft.com/moveitfreely): It is a free commandline FTP client that allows to send the backup file created by 7Zip to a server (local or remote) for storage.

Of course, the "glue" for all this is a batch file like this (launched by "System Scheduler" at desired time):

Code: Select all

cd c:\util

7z u -mx9 -r -mmt=off c:\upload\My.Backup.%date:~-4,4%.%date:~-7,2%.%date:~-10,2%.7z c:\MyFiles\*.*

cd c:\upload

echo put My.Backup.%date:~-4,4%.%date:~-7,2%.%date:~-10,2%.7z > temp.txt
echo quit >> temp.txt

c:\util\ftps -a -e:off -user:myuser -password:mypass -s:temp.txt  my.server.ip  my.server.port

del temp.txt

cd c:\util
I hope this will be useful for someone.

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 1:20 pm
by serge_girard
Thx Roberto !

Serge

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 2:54 pm
by esgici
Roberto Lopez wrote:I'm using a combination of three things:
...
I hope this will be useful for someone.
Extremely simple in appearance and extremely powerful, helpful and useful inside :o

AS ALWAYS :arrow: 8-)

Thank you very much Maestro for everything you gave us :oops:

Viva HMG :D

Re: Programa para BACKUP

Posted: Sat Feb 27, 2016 4:32 pm
by Roberto Lopez
And... the FTP server (for the backup destination machine) I use Filezilla Server. A rock-solid, free FTP server: https://filezilla-project.org/download.php?type=server