Added "Backup GBM data files on launch" feature

This commit is contained in:
MikeMaximus
2018-03-06 13:19:47 -06:00
parent ebc185d7b8
commit b9244eeeae
8 changed files with 92 additions and 26 deletions
+12
View File
@@ -1022,6 +1022,13 @@ Public Class frmMain
oRemoteDatabase.DatabaseUpgrade()
End Sub
Private Sub BackupDatabases()
Dim oLocalDatabase As New mgrSQLite(mgrSQLite.Database.Local)
Dim oRemoteDatabase As New mgrSQLite(mgrSQLite.Database.Remote)
oLocalDatabase.BackupDB(App_BackupOnLaunchFileDescription, True)
oRemoteDatabase.BackupDB(App_BackupOnLaunchFileDescription, True)
End Sub
Private Sub LoadAndVerify()
'If the default utility is missing we cannot continue
@@ -1051,6 +1058,11 @@ Public Class frmMain
VerifyDBVersion(mgrSQLite.Database.Remote)
RemoteDatabaseCheck()
'Backup GBM data
If oSettings.BackupOnLaunch Then
BackupDatabases()
End If
'Sync Game Settings
SyncGameSettings()
End If
+26 -13
View File
@@ -66,6 +66,7 @@ Partial Class frmSettings
Me.chkSessionTracking = New System.Windows.Forms.CheckBox()
Me.lstSettings = New System.Windows.Forms.ListBox()
Me.btnResetMessages = New System.Windows.Forms.Button()
Me.chkBackupOnLaunch = New System.Windows.Forms.CheckBox()
Me.grpStartup.SuspendLayout()
Me.grpFolderOptions.SuspendLayout()
Me.grp7zGeneral.SuspendLayout()
@@ -84,19 +85,20 @@ Partial Class frmSettings
Me.chkMonitorOnStartup.AutoSize = True
Me.chkMonitorOnStartup.Location = New System.Drawing.Point(6, 65)
Me.chkMonitorOnStartup.Name = "chkMonitorOnStartup"
Me.chkMonitorOnStartup.Size = New System.Drawing.Size(146, 17)
Me.chkMonitorOnStartup.Size = New System.Drawing.Size(149, 17)
Me.chkMonitorOnStartup.TabIndex = 2
Me.chkMonitorOnStartup.Text = "Start monitoring at launch"
Me.chkMonitorOnStartup.Text = "Start monitoring on launch"
Me.chkMonitorOnStartup.UseVisualStyleBackColor = True
'
'grpStartup
'
Me.grpStartup.Controls.Add(Me.chkBackupOnLaunch)
Me.grpStartup.Controls.Add(Me.chkStartWindows)
Me.grpStartup.Controls.Add(Me.chkStartToTray)
Me.grpStartup.Controls.Add(Me.chkMonitorOnStartup)
Me.grpStartup.Location = New System.Drawing.Point(6, 12)
Me.grpStartup.Name = "grpStartup"
Me.grpStartup.Size = New System.Drawing.Size(354, 90)
Me.grpStartup.Size = New System.Drawing.Size(354, 112)
Me.grpStartup.TabIndex = 0
Me.grpStartup.TabStop = False
Me.grpStartup.Text = "Startup"
@@ -124,7 +126,7 @@ Partial Class frmSettings
'chkAutoSaveLog
'
Me.chkAutoSaveLog.AutoSize = True
Me.chkAutoSaveLog.Location = New System.Drawing.Point(12, 262)
Me.chkAutoSaveLog.Location = New System.Drawing.Point(12, 280)
Me.chkAutoSaveLog.Name = "chkAutoSaveLog"
Me.chkAutoSaveLog.Size = New System.Drawing.Size(231, 17)
Me.chkAutoSaveLog.TabIndex = 5
@@ -133,7 +135,7 @@ Partial Class frmSettings
'
'btnOptionalFields
'
Me.btnOptionalFields.Location = New System.Drawing.Point(5, 65)
Me.btnOptionalFields.Location = New System.Drawing.Point(6, 65)
Me.btnOptionalFields.Name = "btnOptionalFields"
Me.btnOptionalFields.Size = New System.Drawing.Size(216, 23)
Me.btnOptionalFields.TabIndex = 3
@@ -153,7 +155,7 @@ Partial Class frmSettings
'chkShowDetectionTips
'
Me.chkShowDetectionTips.AutoSize = True
Me.chkShowDetectionTips.Location = New System.Drawing.Point(12, 239)
Me.chkShowDetectionTips.Location = New System.Drawing.Point(12, 257)
Me.chkShowDetectionTips.Name = "chkShowDetectionTips"
Me.chkShowDetectionTips.Size = New System.Drawing.Size(159, 17)
Me.chkShowDetectionTips.TabIndex = 4
@@ -214,7 +216,7 @@ Partial Class frmSettings
Me.btnSave.Location = New System.Drawing.Point(384, 321)
Me.btnSave.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(75, 23)
Me.btnSave.TabIndex = 5
Me.btnSave.TabIndex = 6
Me.btnSave.Text = "&Save"
Me.btnSave.UseVisualStyleBackColor = True
'
@@ -224,7 +226,7 @@ Partial Class frmSettings
Me.btnCancel.Location = New System.Drawing.Point(465, 321)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(75, 23)
Me.btnCancel.TabIndex = 6
Me.btnCancel.TabIndex = 7
Me.btnCancel.Text = "&Cancel"
Me.btnCancel.UseVisualStyleBackColor = True
'
@@ -454,7 +456,7 @@ Partial Class frmSettings
'lblMinutes
'
Me.lblMinutes.AutoSize = True
Me.lblMinutes.Location = New System.Drawing.Point(232, 216)
Me.lblMinutes.Location = New System.Drawing.Point(232, 234)
Me.lblMinutes.Name = "lblMinutes"
Me.lblMinutes.Size = New System.Drawing.Size(43, 13)
Me.lblMinutes.TabIndex = 17
@@ -462,7 +464,7 @@ Partial Class frmSettings
'
'nudSupressBackupThreshold
'
Me.nudSupressBackupThreshold.Location = New System.Drawing.Point(176, 214)
Me.nudSupressBackupThreshold.Location = New System.Drawing.Point(176, 232)
Me.nudSupressBackupThreshold.Maximum = New Decimal(New Integer() {999, 0, 0, 0})
Me.nudSupressBackupThreshold.Name = "nudSupressBackupThreshold"
Me.nudSupressBackupThreshold.Size = New System.Drawing.Size(51, 20)
@@ -471,7 +473,7 @@ Partial Class frmSettings
'chkSupressBackup
'
Me.chkSupressBackup.AutoSize = True
Me.chkSupressBackup.Location = New System.Drawing.Point(12, 215)
Me.chkSupressBackup.Location = New System.Drawing.Point(12, 233)
Me.chkSupressBackup.Name = "chkSupressBackup"
Me.chkSupressBackup.Size = New System.Drawing.Size(158, 17)
Me.chkSupressBackup.TabIndex = 2
@@ -483,7 +485,7 @@ Partial Class frmSettings
Me.grpGameData.Controls.Add(Me.chkSessionTracking)
Me.grpGameData.Controls.Add(Me.chkTimeTracking)
Me.grpGameData.Controls.Add(Me.btnOptionalFields)
Me.grpGameData.Location = New System.Drawing.Point(6, 106)
Me.grpGameData.Location = New System.Drawing.Point(6, 130)
Me.grpGameData.Name = "grpGameData"
Me.grpGameData.Size = New System.Drawing.Size(354, 97)
Me.grpGameData.TabIndex = 1
@@ -513,10 +515,20 @@ Partial Class frmSettings
Me.btnResetMessages.Location = New System.Drawing.Point(128, 321)
Me.btnResetMessages.Name = "btnResetMessages"
Me.btnResetMessages.Size = New System.Drawing.Size(110, 23)
Me.btnResetMessages.TabIndex = 7
Me.btnResetMessages.TabIndex = 5
Me.btnResetMessages.Text = "&Reset Warnings"
Me.btnResetMessages.UseVisualStyleBackColor = True
'
'chkBackupOnLaunch
'
Me.chkBackupOnLaunch.AutoSize = True
Me.chkBackupOnLaunch.Location = New System.Drawing.Point(6, 88)
Me.chkBackupOnLaunch.Name = "chkBackupOnLaunch"
Me.chkBackupOnLaunch.Size = New System.Drawing.Size(185, 17)
Me.chkBackupOnLaunch.TabIndex = 3
Me.chkBackupOnLaunch.Text = "Backup GBM data files on launch"
Me.chkBackupOnLaunch.UseVisualStyleBackColor = True
'
'frmSettings
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -604,4 +616,5 @@ Partial Class frmSettings
Friend WithEvents nudSupressBackupThreshold As NumericUpDown
Friend WithEvents chkSupressBackup As CheckBox
Friend WithEvents btnResetMessages As Button
Friend WithEvents chkBackupOnLaunch As CheckBox
End Class
+3
View File
@@ -47,6 +47,7 @@ Public Class frmSettings
oSettings.MonitorOnStartup = chkMonitorOnStartup.Checked
oSettings.StartToTray = chkStartToTray.Checked
oSettings.BackupOnLaunch = chkBackupOnLaunch.Checked
oSettings.ShowDetectionToolTips = chkShowDetectionTips.Checked
oSettings.AutoSaveLog = chkAutoSaveLog.Checked
oSettings.DisableConfirmation = chkBackupConfirm.Checked
@@ -172,6 +173,7 @@ Public Class frmSettings
chkStartWindows.Checked = oSettings.StartWithWindows
chkMonitorOnStartup.Checked = oSettings.MonitorOnStartup
chkStartToTray.Checked = oSettings.StartToTray
chkBackupOnLaunch.Checked = oSettings.BackupOnLaunch
chkShowDetectionTips.Checked = oSettings.ShowDetectionToolTips
chkAutoSaveLog.Checked = oSettings.AutoSaveLog
chkBackupConfirm.Checked = oSettings.DisableConfirmation
@@ -300,6 +302,7 @@ Public Class frmSettings
lblLocation.Text = frmSettings_lblLocation
btnOptionalFields.Text = frmSettings_btnOptionalFields
btnResetMessages.Text = frmSettings_btnResetMessages
chkBackupOnLaunch.Text = frmSettings_chkBackupOnLaunch
'Unix Handler
If mgrCommon.IsUnix Then
+8 -8
View File
@@ -27,17 +27,17 @@ Public Class mgrSQLite
End Select
End Sub
Private Sub BackupDB(ByVal sLastVer As String)
Public Sub BackupDB(ByVal sDescription As String, Optional ByVal bOverwrite As Boolean = False)
Dim sNewFile As String = String.Empty
Try
Select Case eDatabase
Case Database.Local
sNewFile = mgrPath.DatabaseLocation & "." & sLastVer & ".bak"
File.Copy(mgrPath.DatabaseLocation, sNewFile, False)
sNewFile = mgrPath.DatabaseLocation & "." & sDescription & ".bak"
File.Copy(mgrPath.DatabaseLocation, sNewFile, bOverwrite)
Case Database.Remote
sNewFile = mgrPath.RemoteDatabaseLocation & "." & sLastVer & ".bak"
File.Copy(mgrPath.RemoteDatabaseLocation, sNewFile, False)
sNewFile = mgrPath.RemoteDatabaseLocation & "." & sDescription & ".bak"
File.Copy(mgrPath.RemoteDatabaseLocation, sNewFile, bOverwrite)
End Select
Catch ex As Exception
mgrCommon.ShowMessage(mgrSQLite_ErrorBackupFailure, New String() {sNewFile, ex.Message}, MsgBoxStyle.Exclamation)
@@ -75,7 +75,7 @@ Public Class mgrSQLite
"BackupFolder TEXT NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL, " &
"SupressBackup BOOLEAN NOT NULL, SupressBackupThreshold INTEGER NOT NULL, CompressionLevel INTEGER NOT NULL, Custom7zArguments TEXT, " &
"Custom7zLocation TEXT, SyncFields INTEGER NOT NULL, AutoSaveLog BOOLEAN NOT NULL, AutoRestore BOOLEAN NOT NULL, AutoMark BOOLEAN NOT NULL, SessionTracking BOOLEAN NOT NULL, " &
"SupressMessages INTEGER NOT NULL);"
"SupressMessages INTEGER NOT NULL, BackupOnLaunch BOOLEAN NOT NULL);"
'Add Tables (SavedPath)
sSql &= "CREATE TABLE savedpath (PathName TEXT NOT NULL PRIMARY KEY, Path TEXT NOT NULL);"
@@ -773,12 +773,12 @@ Public Class mgrSQLite
"BackupFolder TEXT NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL, " &
"SupressBackup BOOLEAN NOT NULL, SupressBackupThreshold INTEGER NOT NULL, CompressionLevel INTEGER NOT NULL, Custom7zArguments TEXT, " &
"Custom7zLocation TEXT, SyncFields INTEGER NOT NULL, AutoSaveLog BOOLEAN NOT NULL, AutoRestore BOOLEAN NOT NULL, AutoMark BOOLEAN NOT NULL, SessionTracking BOOLEAN NOT NULL, " &
"SupressMessages INTEGER NOT NULL);"
"SupressMessages INTEGER NOT NULL, BackupOnLaunch BOOLEAN NOT NULL);"
sSQL &= "INSERT INTO settings_new(SettingsID, MonitorOnStartup, StartToTray, ShowDetectionToolTips, DisableConfirmation, CreateSubFolder, ShowOverwriteWarning, RestoreOnLaunch, " &
"BackupFolder, StartWithWindows, TimeTracking, SupressBackup, SupressBackupThreshold, CompressionLevel, Custom7zArguments, Custom7zLocation, SyncFields, AutoSaveLog, " &
"AutoRestore, AutoMark, SessionTracking, SupressMessages) SELECT SettingsID, MonitorOnStartup, StartToTray, ShowDetectionToolTips, DisableConfirmation, CreateSubFolder, ShowOverwriteWarning, RestoreOnLaunch, " &
"BackupFolder, StartWithWindows, TimeTracking, SupressBackup, SupressBackupThreshold, CompressionLevel, Custom7zArguments, Custom7zLocation, SyncFields, AutoSaveLog, " &
"AutoRestore, AutoMark, SessionTracking, 0 FROM settings;" &
"AutoRestore, AutoMark, SessionTracking, 0, 1 FROM settings;" &
"DROP TABLE settings; ALTER TABLE settings_new RENAME TO settings;"
sSQL &= "CREATE TABLE monitorlist_new (MonitorID TEXT NOT NULL PRIMARY KEY, Name TEXT NOT NULL, Process TEXT NOT NULL, Path TEXT, " &
"AbsolutePath BOOLEAN NOT NULL, FolderSave BOOLEAN NOT NULL, FileType TEXT, TimeStamp BOOLEAN NOT NULL, ExcludeList TEXT NOT NULL, " &
+13 -1
View File
@@ -22,6 +22,7 @@ Public Class mgrSettings
Private eSyncFields As clsGame.eOptionalSyncFields = clsGame.eOptionalSyncFields.None Or clsGame.eOptionalSyncFields.TimeStamp
Private eMessages As eSupressMessages = eSupressMessages.None
Private bAutoSaveLog As Boolean = False
Private bBackupOnLaunch As Boolean = True
<Flags()> Public Enum eSupressMessages
None = 0
@@ -265,6 +266,15 @@ Public Class mgrSettings
End Set
End Property
Property BackupOnLaunch As Boolean
Get
Return bBackupOnLaunch
End Get
Set(value As Boolean)
bBackupOnLaunch = value
End Set
End Property
Sub New()
'The GameIDsync message should be supressed on all new databases
SetMessageField(SupressMessages, eSupressMessages.GameIDSync)
@@ -281,7 +291,7 @@ Public Class mgrSettings
sSQL = "INSERT INTO settings VALUES (1, @MonitorOnStartup, @StartToTray, @ShowDetectionToolTips, @DisableConfirmation, "
sSQL &= "@CreateSubFolder, @ShowOverwriteWarning, @RestoreOnLaunch, @BackupFolder, @StartWithWindows, "
sSQL &= "@TimeTracking, @SupressBackup, @SupressBackupThreshold, @CompressionLevel, @Custom7zArguments, @Custom7zLocation, "
sSQL &= "@SyncFields, @AutoSaveLog, @AutoRestore, @AutoMark, @SessionTracking, @SupressMessages)"
sSQL &= "@SyncFields, @AutoSaveLog, @AutoRestore, @AutoMark, @SessionTracking, @SupressMessages, @BackupOnLaunch)"
hshParams.Add("MonitorOnStartup", MonitorOnStartup)
hshParams.Add("StartToTray", StartToTray)
@@ -304,6 +314,7 @@ Public Class mgrSettings
hshParams.Add("AutoMark", AutoMark)
hshParams.Add("SessionTracking", SessionTracking)
hshParams.Add("SupressMessages", SupressMessages)
hshParams.Add("BackupOnLaunch", BackupOnLaunch)
oDatabase.RunParamQuery(sSQL, hshParams)
End Sub
@@ -339,6 +350,7 @@ Public Class mgrSettings
AutoMark = CBool(dr("AutoMark"))
SessionTracking = CBool(dr("SessionTracking"))
SupressMessages = CInt(dr("SupressMessages"))
BackupOnLaunch = CBool(dr("BackupOnLaunch"))
Next
oDatabase.Disconnect()
+18
View File
@@ -60,6 +60,15 @@ Namespace My.Resources
End Set
End Property
'''<summary>
''' Looks up a localized string similar to launch.
'''</summary>
Friend ReadOnly Property App_BackupOnLaunchFileDescription() As String
Get
Return ResourceManager.GetString("App_BackupOnLaunchFileDescription", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to There are unsaved changes on this form. Do you want to save?.
'''</summary>
@@ -4155,6 +4164,15 @@ Namespace My.Resources
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Backup GBM data files on launch.
'''</summary>
Friend ReadOnly Property frmSettings_chkBackupOnLaunch() As String
Get
Return ResourceManager.GetString("frmSettings_chkBackupOnLaunch", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to Create a sub-folder for each game.
'''</summary>
+6
View File
@@ -2065,4 +2065,10 @@
<data name="mgrMonitorList_GameIDSyncCompleted" xml:space="preserve">
<value>Sync Complete.[BR][BR][PARAM] game configurations were matched and updated.</value>
</data>
<data name="App_BackupOnLaunchFileDescription" xml:space="preserve">
<value>launch</value>
</data>
<data name="frmSettings_chkBackupOnLaunch" xml:space="preserve">
<value>Backup GBM data files on launch</value>
</data>
</root>
+6 -4
View File
@@ -8,9 +8,9 @@ New in 1.1.0
Disclaimer:
Version 1.1.0 makes fundamental changes to how GBM works with game configurations and backup data. Please read the changes below carefully.
Version 1.1.0 makes fundamental changes to how GBM works with game configurations and backup data, in addition to many other changes. Please read the changes below carefully before upgrading.
I've done my best to make sure the upgrade process is seamless and allows everyone to continue using their existing data and configurations.
I've done my best to make sure the upgrade process allows everyone to continue using their existing data and configurations.
All Platforms:
@@ -21,7 +21,10 @@ All Platforms:
- Game Name can now contain any character.
- When a game is deleted via Game Manager (or sync), all backup manifest entries for that particular game are now deleted. The backup files themselves are not.
- The Game Manager now syncs changes to the remote database immediately, instead of only when closed.
- Core Design Changes (Features)
- Feature Changes
- Added "Backup GBM data files on launch" to the settings. A long overdue feature, this will backup both the remote and local databases (as gbm.s3db.launch.bak) each time GBM starts.
- This new setting is enabled by default.
- Only one backup is kept, the prior one will be overwritten.
- Added the ability to display messages that can be supressed. These messages can be reset via the Settings screen.
- The "Enable Sync" feature is now mandatory and the option been removed from Settings.
- The "Clean Local Manifest" feature has been removed. It is not required because manfiest entries are no longer orphaned by design. Existing orphaned entries will be removed during the v1.1.0 database upgrade.
@@ -55,6 +58,5 @@ Known Issues:
- If one or more Game IDs are changed on one computer and these changes are synced to another PC sharing the same backup folder:
- The local session data on that PC for the changed game(s) will be lost.
- The local backup manifest data for the changed game(s) on that PC will be reset. GBM will see any backups for the changed game(s) as new and will handle them accordingly.
- If the "Create a sub-folder..." option is enabled, GBM may leave empty folders when backups are updated or deleted. This only only applies to folders created with a prior version of GBM.
The entire version history of GBM releases is available at http://mikemaximus.github.io/gbm-web/versionhistory.html