I'm working on something that will backup and save said backup of a database to a specified location. I'd like to know if there's a way to compress the .bak
file after it's generate, but before I actually save it to its destination without getting the backup, zipping the .bak
and then deleting the uncompressed version.
SqlConnection objconnection = new SqlConnection(connString);
ServerConnection con = new ServerConnection(objconnection.DataSource.ToString());
Server server = new Server(con);
Backup source = new Backup();
source.Action = BackupActionType.Database;
source.Database = dbName;
BackupDeviceItem destination = new BackupDeviceItem(dbName+".bak" , DeviceType.File);
//-->Zip the backup prior to actually saving backup
source.Devices.Add(destination);
source.SqlBackup(server);
Apparently this isn't possible and I have to create the .BAK backup file and then compress/zip it before sending it off.