Question

madlan on Mon, 25 Mar 2013 16:29:26


Is it possible to backup via SMO to a stream rather than directly to file? (I would like to compress the file before writing.)

Dim Server As Server = New Server(SQLServer)
Dim bak As Backup = New Backup()

bak.Devices.AddDevice(BackupFilePath, DeviceType.File)
bak.Database = DatabaseName
bak.Action = BackupActionType.Database
bak.Initialize = True
bak.SqlBackup(Server)

VB.NET


Sponsored



Replies

Iric Wen on Tue, 26 Mar 2013 09:00:15


Hi madlan,

As per my knowledge, we can only backup database to a file and then compress it to a stream following the below two steps:

1.Backup and Restore SQL Server databases programmatically with SMO:

http://www.mssqltips.com/sqlservertip/1849/backup-and-restore-sql-server-databases-programmatically-with-smo/

2.Backup compression and Virtual Device Interface (VDI)

http://blogs.msdn.com/b/sqlserverstorageengine/archive/2010/02/21/backup-compression-and-virtual-device-interface-vdi.aspx

If you have any feedback on our support, please click here.


Iric Wen
TechNet Community Support


madlan on Tue, 26 Mar 2013 09:33:50


Oh well, thanks for replying.