Пример #1
0
        void Database.BackupTransactionLog(string folderPath)
        {
            Directory.CreateDirectory(folderPath);
            ExecuteDbMethod(
                cn => {
                var newId = new InlineInsert("MainSequence").Execute(cn);
                var newTransactionLogBackupFileName = newId + " " + StandardLibraryMethods.GetLocalHostName();


                // We definitely do not want the following statements in a transaction because we want to be sure that the insert is included in the backup. Also, if
                // the insert succeeds and the backup fails, that is totally fine.

                var insert = new InlineInsert("RsisLogBackups");
                insert.AddColumnModification(new InlineDbCommandColumnValue("RsisLogBackupId", new DbParameterValue(newId, "Int")));
                insert.AddColumnModification(new InlineDbCommandColumnValue("DateAndTimeSaved", new DbParameterValue(DateTime.Now, "DateTime2")));
                insert.AddColumnModification(
                    new InlineDbCommandColumnValue("TransactionLogFileName", new DbParameterValue(newTransactionLogBackupFileName, "VarChar")));
                insert.Execute(cn);

                var filePath = StandardLibraryMethods.CombinePaths(folderPath, newTransactionLogBackupFileName);
                executeLongRunningCommand(cn, "BACKUP LOG " + info.Database + " TO DISK = '" + filePath + "'");
            });
        }