使用 C# 和SMO,如何向 SQL Server 添加备份设备?
我知道如何使用 C# 和 SMO 在 SQL Server 上创建文件备份:
public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server,
string databaseName, string backupFilename,
string backupName, string backupDescription) {
Backup backup = new Backup();
backup.Devices.AddDevice(backupFilename, DeviceType.File);
backup.Database = databaseName;
backup.Action = BackupActionType.Database;
backup.BackupSetDescription = backupDescription;
backup.BackupSetName = backupName;
backup.Incremental = false;
backup.LogTruncation = BackupTruncateLogType.Truncate;
backup.Initialize = true; // supposed to overwrite
backup.SqlBackup(server);
}
我不知道(也找不到)的是如何将文件 BackupDevice 添加到 SQL Server。
I know how to use C# and SMO to create a file backup on a SQL Server:
public void BackupDatabase(Microsoft.SqlServer.Management.Smo.Server server,
string databaseName, string backupFilename,
string backupName, string backupDescription) {
Backup backup = new Backup();
backup.Devices.AddDevice(backupFilename, DeviceType.File);
backup.Database = databaseName;
backup.Action = BackupActionType.Database;
backup.BackupSetDescription = backupDescription;
backup.BackupSetName = backupName;
backup.Incremental = false;
backup.LogTruncation = BackupTruncateLogType.Truncate;
backup.Initialize = true; // supposed to overwrite
backup.SqlBackup(server);
}
What I don't know (and can't find) is how to add the file BackupDevice to the SQL server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用备份设备。创建:
Use BackupDevice.Create: