← Back to Guides Homepage

Complete SQL Server Backup & Maintenance with Ola Hallengren

In this guide, we will install and configure the industry-standard SQL Server Maintenance Solution by Ola Hallengren. This solution handles backups, integrity checks, and index optimization automatically. It is trusted by organizations like NASA, HP, and Microsoft.

Step 1: Prerequisites and Download

Before we begin, ensure your SQL Server Agent service is running, as it is required to execute the scheduled jobs.

1. Enable SQL Server Agent

Open Services (services.msc) and locate SQL Server Agent. Set its Startup Type to Automatic and start the service. It depends on the main SQL Server service, so ensure that is running as well.

2. Download the Solution

Visit ola.hallengren.com and download the MaintenanceSolution.sql script. This single script contains everything needed for backups, integrity checks, and index maintenance.

Step 2: Install and Configure the Script

Open SQL Server Management Studio (SSMS) and connect to your instance. Drag and drop the downloaded MaintenanceSolution.sql file into the query window.

1. Configure Backup Settings

You can customize the script parameters before execution. Although optional (it uses default server paths otherwise), it is good practice to review these:

2. Execute the Script

Once configured, press Execute (F5). You should see "Command completed successfully." This creates all the necessary stored procedures and SQL Agent jobs.

Step 3: Verify and Test Backups

Expand the SQL Server Agent > Jobs folder. You will see a list of new jobs created by the script (e.g., DatabaseBackup - USER_DATABASES - FULL).

1. Run a Manual Backup

To test, right-click the DatabaseBackup - USER_DATABASES - FULL job and select "Start Job at Step...". This will immediately back up all user databases.

2. Verify Backup Files

Navigate to your backup directory. You should see a folder structure created for your server and databases, containing the compressed backup files (.bak). Check that the file size is compressed compared to the actual database size.

Step 4: Scheduling the Jobs

The jobs are created but not scheduled. You must define when they run. Here is a recommended weekly schedule for a standard production environment:

Saturday Maintenance Window

Daily Routine (Sunday - Friday)

Transaction Logs

← Back to Guides Homepage