Esempio n. 1
0
        private void DatabaseBackupThread_OnStageChanged(SharedControls.Classes.Backup.DatabaseBackupStage e)
        {
            SendToTCPClients(String.Format("{0} Backup Status: {1}", _databaseConnection.Name, e.ToString()));

            if (e == SharedControls.Classes.Backup.DatabaseBackupStage.BackupComplete)
            {
                _databaseConnection.LastBackup = DateTime.Now.AddDays(1).ToFileTime();
                DatabaseConnection.Save(_databaseConnection, _filePath, Forms.Configuration.ENCRYPRION_KEY);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Checks when the database was last backed up, if more than 24 hours performs a backup
        /// and uploads to the server
        /// </summary>
        private void CheckLatestDBBackup()
        {
            string name = "Database Backup Thread";

            if (Shared.Classes.ThreadManager.Exists(name))
            {
                return;
            }

            TimeSpan span = DateTime.Now - _databaseConnection.LastBackupTime;

            if (span.TotalDays < 1.0)
            {
                return;
            }

            span = DateTime.Now - _databaseConnection.LastBackupAttemptTime;

            // try every six hours
            if (span.TotalHours < 6.0)
            {
                return;
            }

            _databaseConnection.LastBackupAttempt = DateTime.Now.ToFileTime();
            DatabaseConnection.Save(_databaseConnection, _filePath, Forms.Configuration.ENCRYPRION_KEY);

            if (_databaseConnection.BackupDeleteOldFiles)
            {
                Shared.Utilities.FileDeleteOlder(
                    _databaseConnection.BackupPath,
                    String.Format("Backup*.{0}", _databaseConnection.BackupCompress ? "zip" : "fbk"),
                    _databaseConnection.BackupMaximumAge);
            }

            SharedControls.Classes.Backup.DatabaseBackupThread.BackupDatabase(
                _databaseConnection.BackupPath, _databaseConnection.BackupCopyRemote,
                _databaseConnection.BackupUseSiteID, _databaseConnection.SiteID,
                _databaseConnection.BackupName, name,
                _databaseConnection.ChildDatabase, _databaseConnection.BackupFTPHost,
                _databaseConnection.BackupFTPUsername, _databaseConnection.BackupFTPPassword,
                _databaseConnection.BackupFTPPort);
        }