Welcome! Log In Create A New Profile

Advanced

HFCS backup

Posted by Arie 
Arie
HFCS backup
February 02, 2009 05:24PM
Hi, for one of my customers I'm using a scheduled task to perform backups (HFCS). I want to keep these backups for let says one month. This way I can do support, by retrieving a backup to my own machine

Best way would be let the tape-software take care of that. After a succesfull tape-backup, the hfcs-backup can be deleted. But as I mentioned, I like those backup to be available a little bit longer. Some backup software can do that, others cannot.

Now I want to delete these backups after 30 days. Via HF control centre I dont see any option. Do you have any other smart options?

Arie
Michael Drechsel
Re: HFCS backup
February 02, 2009 08:20PM
Hi Arie,

try this:

[www.miditas.de]

its free.
Jeff Graham
Re: HFCS backup
February 02, 2009 08:20PM
Hi Arie,

What we do is rename our HFCS zipped backups with a date-time extension added. Then we delete all that have an extension older than 15 days. If you would like the code, just let me know.

We wrote our own backup for HFCS in zipped format back in version 10. We do not use the HF CC backups.

Arie
Re: HFCS backup
February 02, 2009 08:59PM
Jeff, if you are willing to share this code, it would be great! (arie.mars_at_ gmail.com)

I did not have time yet to "zip" backups. Some of my data is over 500mb, but just 20mb when zipped!!


Note: hfcs backup is very, very slow. Looks like if it done record-by-record, being a hot-backup...

Arie
Arie
Re: HFCS backup
February 02, 2009 09:03PM
Thanks Michael, I will give it a try. I already made some stored procs to be able to delete old backups. I call them from my application. But did not have time to make a BackupGuard!

I wrote a piece of code myself, to transfer a server-backup to a client and save it there.

For those who are interested: backup files are NOT in hfserver\bdd, so you cannot reach them from your client through H-command like HCopyFile()

So I use a stored procedure to fCopyFile the backup files into a temp-database .
Then I use HCopyFile() to transfer all files of this temp-database to the client, which is done through port 4900.
This way I can copy a hfcs-backup (or even scheduled backup) from a server to the client. Very handy when you don't have physical access to the hfcs-machine.

Arie
Jeff Graham
Re: HFCS backup
February 03, 2009 09:22PM
Arie, here is the code. If you have any questions, let me know.

PROCEDURE BackUpData(lvZipName="Backup.zip")

HourGlass(True)

// Check users connected to data base
IF sServer > " " THEN
sUserList,sUserNames,sWork are strings
sUserNames = ""
sUserList = HListConnectedUser(sConnectionName,sServerDBName)
FOR EACH STRING sWork OF sUserList SEPARATED BY CR
sWork = ExtractString(sWork,2,TAcool smiley + ", "
IF Position(sUserNames,sWork) = 0 THEN
sUserNames += sWork
END
END
sUserNames = sUserNames[[1 TO Length(sUserNames)-2]]
IF Position(sUserNames,", ",1) > 0 THEN
// Disconnect all the users from "MAILBOX"
IF YesNo("Cannot proceed when other users are connected.","Machines connected are "+sUserNames,"Do you want to disconnect all other users?") THEN
HClient.Database = sServerDBName
Message("Disconnecting Users. May take up to 30 seconds...")
IF NOT HDisconnectClient(sConnectionName, "Caution: Backup beginning. You will be disconnected.",30) THEN
Error("Cannot disconnect users.","Please close all applications and reboot.", "Then try backup again.")
HourGlass(False)
RESULT -1
END
ELSE
HourGlass(False)
RESULT -1
END
END
END

Message("Creating Data Backup. "+ lvZipName)
iResult is int
iEvent is int
sZip is string = lvZipName
//sZipFile is string = fExtractPath(Left(g_DataDir,(Length(g_DataDir)-1)),fDrive+fDirectory)+sZip
sZipFile is string = g_DataDir+sZip

IF fFileExist(sZipFile) THEN // fDelete(sZipFile)
IF NOT fRename(sZipFile,sZipFile+"."+DateToString(DateSys(),"YYYYMMDD")+TimeToString(TimeSys(),"HHMMSS")) THEN
Error("Unable to rename " + sZipFile,ErrorInfo(errFullDetails))
// result -1
END
fListFile(sZipFile+"."+DateToString(DateSys(),"YYYY")+"*",BackupDelete)
END

iResult = zipCreate(sZip,sZipFile)
IF iResult = 0 THEN
// Changed C/S backup to use hCopyFile to data directory See new code below
// if g_MultiUser or sServer <> "" then
// sDataLocation = sServerDataPath
// if not fFileExist(sDataLocation+"Accounts.Fic") then
// error("Unable to access data files in " + sServerDataPath, ...
// "Backup cannot be made.", ...
// "If there are multiple computers, make sure all are off.")
// result -1
// END
// end

HClose("*")
// HCloseConnection(sConnectionName)
// Multitask(10)
iEvent = Event("ZipBar",WinInput(),CompressGauge)

// if iResult = 0 then iResult = zipAddDirectory(sZip,fExtractPath(g_DataDir,fDrive+fDirectory),False,zipRelative)
// Above replaced by the following:
sBackupFileList = ""
sBackupFileList = HListFile()
// flistfile(sDataLocation+"*.fic","BackupFileList")
// fListFile(sDataLocation+"*.ndx","BackupFileList")
// fListFile(sDataLocation+"*.mmo","BackupFileList")
// sExeDir is string = CompleteDir(fCurrentDir())
// fCurrentDir(g_DataDir)
// if iResult = 0 then iResult = zipAddFileList(sZip,sBackupFileList)
// fCurrentDir(sExeDir)
iCount is int = 1
sExcludeList is string = ...
",DistrictFile,Fingerprints,FrrdAccts,ImportAccounts,LifeTouch,NewAccounts,OldStudents,PriorYearStudents,TempRegister,WorkAccounts,"
// sExcludeList must start and end with comma

sDataLocation is string = g_DataDir
IF sServer > "" THEN
sBackUpDir is string = g_DataDir+"Backup\"
IF NOT fDirectoryExist(sBackUpDir) THEN
IF NOT fMakeDir(sBackUpDir) THEN
Error("Unable to make "+sBackUpDir,"Directory required to backup C/S files.",ErrorInfo())
RESULT -1
END
END
sDataLocation = sBackUpDir
END
sFileName is string
sFileName = ExtractString(sBackupFileList,iCount,CR)
sPhysicalFileName is string
WHILE sFileName <> EOT
IF Position(sExcludeList,","+ExtractString(sFileName, 1, ".")+",",1,IgnoreCase) = 0 ...
AND NOT Lower(sFileName) [= "work" THEN
sPhysicalFileName = {sFileName,indFile}..PhysicalName+...
{sFileName,indFile}..Extension
IF g_MultiUser OR sServer > "" THEN
IF NOT HCopyFile("",sDataLocation+sPhysicalFileName,sConnectionName,sPhysicalFileName,hCopyIndex) THEN
Error("Unable to copy file from server "+sServer,sPhysicalFileName,HErrorInfo(hErrBaseMessage))
iResult = -1
BREAK
END
END
iResult = zipAddFile(sZip,sDataLocation + sPhysicalFileName,zipNone)
iResult = zipAddFile(sZip,sDataLocation + {sFileName,indFile}..PhysicalName+".ndx",zipNone)
IF fFileExist(sDataLocation + {sFileName,indFile}..PhysicalName+".mmo") THEN
iResult = zipAddFile(sZip,sDataLocation + {sFileName,indFile}..PhysicalName+".mmo",zipNone)
END
IF iResult <> 0 THEN BREAK
END
iCount += 1
sFileName = ExtractString(sBackupFileList,iCount,CR)
END
sBackupFileList = ""

// note: not backuping .ini file because if restored on machine other than the current one doing a backup, the information is not correct.
// if iresult = 0 then
// iCount = 1
// sBackupFileList = fListFile(fExeDir()+"\accmeals.ini",frNotRecursive) // ,"BackupFileList")
// sFileName = ExtractString(sBackupFileList,iCount,cr)
// while sFileName <> eot
// iresult = zipAddFile(sZip,sFileName,zipDrive)
// if iResult <> 0 then break
// icount += 1
// sFileName = ExtractString(sBackupFileList,iCount,cr)
// END
// sBackupFileList = ""
// end

IF iResult = 0 THEN
iCount = 1
sBackupFileList = fListFile(g_DataDir+"*.mdb",frNotRecursive) //,"BackupFileList")
IF sBackupFileList > "" THEN sBackupFileList += CR
sBackupFileList += fListFile(g_DataDir+"VFLicense*.txt",frNotRecursive) //,"BackupFileList")
sFileName = ExtractString(sBackupFileList,iCount,CR)
WHILE sFileName > "" AND sFileName <> EOT
iResult = zipAddFile(sZip,sFileName,zipDrive)
IF iResult <> 0 THEN BREAK
iCount += 1
sFileName = ExtractString(sBackupFileList,iCount,CR)
END
sBackupFileList = ""
END

zipClose(sZip)
IF iResult = 0 THEN
IF lvZipName = "Backup.zip" THEN // If primary backup, copy to backup path, else don't copy
// sBackupPath is string
bRegRead is boolean
WHILE iResult = 0
sBackupPath = INIRead("Files", "Backup_Path", "<None>", g_IniFile)
//if not bRegRead then
IF sBackupPath = "<None>" THEN
sBackupPath = fSelectDir(CompleteDir(sBackupPath), "Select a directory...", "Specify drive or path for backup file.")
// IF sBackupPath <> "" then
// bRegRead = INIWrite("Files", "Backup_Path", sBackupPath, g_IniFile)
// if not bRegRead then
// info("Unable to set Backup_Path value in ini file.")
// END
// END
END
IF sBackupPath <> "" THEN
IF NOT fCopyFile(sZipFile,sBackupPath,frConfirm+frProgress) THEN
IF YesNo("Copy failed.",ErrorInfo(errMessage),"Do you want to try again?") = No THEN
iResult = 9
END
ELSE
BREAK
END
ELSE
IF YesNo("You did not select a drive for backup.","Do you want to try again?") = No THEN
iResult = 9
END
END
END
END
ELSE
IF iResult > 0 THEN Error("Zip error has occurred:",zipMsgError(iResult),"Last File was "+sFileName)
END
EndEvent(iEvent)
// OpenDataConnection()
ELSE
Error(zipMsgError(iResult))
END

IF iResult = 0 THEN Info("Backup complete.",sZipFile)
Message("")
HourGlass(False)
RESULT iResult
Arie
Re: HFCS backup - thanks
February 04, 2009 09:32AM
Nice work Jeff. Thanks.

Because I don't have access to the hfcs by a drive-letter or unc-path, I can't use HCopyFile. Because HCopyFile cannot operate outside HF-root, if a hfcs connection is used. While backups ARE created outside hf-root.

So I made a workaround. Using fCopyFile() in a stored procedure I have access to the backup-map. First I copy a backup to a temporary map under hf-root. And then I open a connection to it, as if it were a regular database. From this point HCopyFile() can be used, as in your code.

When databased grow, it's rather slow. I think pcsoft should improve "backup".

Arie
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: