Backup SQL database

Backing up databases to protect application data should be a common practice in most organizations. Using a Runbook in Octopus can make this process easy and simple allowing you to run backups ad-hoc or on a scheduled trigger.

Permissions

In this example, you will be backing up a Microsoft SQL Server database using a step template from our community library called SQL - Backup Database. This template supports both:

  • SQL Authentication.
  • Integrated Authentication.

In this example, we’ll use SQL Authentication and provide both a SQL username and password. It’s important to check that you have the correct permissions to perform the backup. You can find more information on this here.

Create the runbook

  1. To create a runbook, navigate to Project ➜ Operations ➜ Runbooks ➜ Add Runbook.
  2. Give the Runbook a name and click SAVE.
  3. Click DEFINE YOUR RUNBOOK PROCESS, then click ADD STEP.
  4. Add a new step template from the community library called SQL - Backup Database.
  5. Fill out all the parameters in the step. It’s best practice to use variables rather than entering the values directly in the step parameters.
ParameterDescriptionExample
ServerDatabase connection stringdbserver01
DatabaseName of database to backupmydatabase
Backup DirectoryPath to backup data file toC:\backups\
SQL LoginSQL Usernameadmin
SQL PasswordSQL PasswordPa$$word
Compression OptionDisable or enable compressionEnabled
DevicesNumber of backup devices to use for backup1
Backup File SuffixSuffix added to backup file nameprod
Connection TimeoutHow long the backup should run3600
Backup ActionFull or incremental backupFULL
Copy OnlyJust do a copy only backupTrue

Use variables where possible so you can assign scopes to values. This will ensure credentials and database connections are correct for the environment you’re deploying to.

After adding all of the required parameters, click Save, and you have a basic runbook to backup your SQL database! You can also add additional steps to add security to your runbooks, such as a manual intervention step for business approvals.

Samples

We have a Target - Windows Space on our Samples instance of Octopus. You can sign in as Guest to take a look at this example and more runbooks in the OctoFX project.

Learn More

Help us continuously improve

Please let us know if you have any feedback about this page.

Send feedback

Page updated on Wednesday, October 4, 2023