Quantcast
Channel: MSBuild Extension Pack
Viewing all articles
Browse latest Browse all 1211

Closed Feature: Add Database Compression [10631]

$
0
0
I would love if someone could add compression options to the database backup task. I have a 60GB db to backup and without compression it is not usable. The following is what I added to the SQL2008 Database.cs file:

//added global private variable
private BackupCompressionOptions compressionOption = BackupCompressionOptions.Default;

//added public property
/// <summary>
/// Sets the compression option for the backup. Default is Default (Other options - On/Off).
/// </summary>
[TaskAction(BackupTaskAction, false)]
public string CompressionOption
{
get { return this.compressionOption.ToString(); }
set { this.compressionOption = (BackupCompressionOptions)Enum.Parse(typeof(BackupCompressionOptions), value); }
}

//added the following line to the backup task
private void Backup()
{
if (!this.VerifyDatabase())
{
return;
}

this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Backing up SQL {2}: {0} to: {1}", this.DatabaseItem.ItemSpec, this.DataFilePath.GetMetadata("FullPath"), this.BackupAction));
Backup sqlBackup = new Backup();
sqlBackup.Devices.AddDevice(this.DataFilePath.GetMetadata("FullPath"), DeviceType.File);
sqlBackup.Database = this.DatabaseItem.ItemSpec;
sqlBackup.Incremental = this.Incremental;
sqlBackup.CopyOnly = this.CopyOnly;
sqlBackup.CompressionOption = this.compressionOption;
sqlBackup.Action = this.backupAction;
sqlBackup.Initialize = true;
sqlBackup.PercentCompleteNotification = this.NotificationInterval;
sqlBackup.PercentComplete += this.ProgressEventHandler;
sqlBackup.SqlBackup(this.sqlServer);
}

Thanks,

John Grzegorczyk
Comments: Resolved with changeset 75470.

Viewing all articles
Browse latest Browse all 1211


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>