I want to backup my database using SMO and zip a backup file then upload it to my server. here is my code
// Backup
var conn = new SqlConnection(sqlConnectionString);
var server = new Server(new ServerConnection(conn));
var backupMgr = new Backup();
backupMgr.Devices.AddDevice(file.FullName, DeviceType.File);
backupMgr.Database = dictionary[StringKeys.Database];
backupMgr.Action = BackupActionType.Database;
backupMgr.SqlBackup(server);
// Compress
using (var zip = new ZipFile())
{
zipFile = string.Format("{0}\\{1}.zip", directoryName, DateTime.Now.ToString("yyyyMMddHHmm"));
zip.AddFile(outputPath, "");
zip.Save(zipFile);
}
// uploading code
Size of a backup file can be more than 100MB. But after i zip this using above code, it doesn't reduce the size. So I cannot upload larger zip files. Is there way to reduce the file size with DotNetZip?
you can do that by adding the following line before save
Alternatively you can refer to following link for detailed answer Compression issue with large archive of files in DotNetZip
Pl. Note: the Library has limitations in compressing image files, the above link will give you a clear understanding of whether the file is getting compressed or not. You can also refer http://dotnetzip.herobo.com/DNZHelp/Index.html for additional help on this topic