GadgetGuy Super User
Joined: June 01 2008 Location: United States
Online Status: Offline Posts: 942
|
Posted: June 19 2013 at 07:30 | IP Logged
|
|
|
It is a good practice to use the PH database backup function to periodically save your PH conditions, using the "ph_backupdb" function.
I automatically run this function every night using a Timed Event. To keep the backups distinct (rather than writing over the last one) I append a date string to the file name.
The construct looks like this . . .
Code:
ph_backupdb("C:\powerhome\Database\dbAutoBaks\PH-"+string(to day(),"yymmdd")+".db",0)
/* Backup PH database file */. |
|
|
Where I have created a folder called "dbAutoBaks" within the PowerHome/Database folder.
The saved db file names look like this "ph-130619.db"
To manage the buildup of files that would occur over time I wrote a VB .Net program to trim the db files in the folder to 30 days worth.
I run this in the same Timed Event sequence that does the backup.
This ph formula calls my compiled fileTrim executable . . .
Code:
ph_run("C:\powerhome\phFileTrim.exe") |
|
|
Here is the VB program so that you can customize it to fit your environment. This is run as a Windows Forms Application . . .
This was written in VB .Net 4.5, but I believe will run on from 2-4.5.
Code:
Imports System
Imports System.IO
Imports System.Security.AccessControl
Public Class phFileTrim
Private Sub fileTrim_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim text As String
Dim UserAccount As String = "Admin"
Dim intdays As Integer = 30
Dim filePath As String = "C:\powerhome\Database\dbAutoBaks"
Dim fi As IO.FileInfo = New IO.FileInfo(filePath)
For Each fi In New IO.DirectoryInfo(filePath).GetFiles("*.*")
Try
If (Now - fi.CreationTime).Days > intdays Then
fi.IsReadOnly = False
fi.Delete()
End If
Catch ex As Exception
text = "File Delete Failed: " & ex.ToString
MsgBox(text)
End Try
Next
Me.Close()
End Sub
End Class
|
|
|
__________________ Ken B - Live every day like it's your last. Eventually, you'll get it right!
|