Cannot Backup to Network Share using Ola Hallengren's Scripts

All we need is an easy explanation of the problem, so here it is.

SQL Version: Microsoft SQL Server 2016(SP3)(KB5003279) – 13.0.6300.2 (X64)

OS Version: Windows Server 2012 R2 Standard

I am trying to setup the backups and database maintenance jobs using Ola Hallengren’s sripts. I have the following job setup:

sqlcmd -E -S $(ESCAPE_SQUOTE(SRVR)) -d master -Q "
    EXECUTE dbo.DatabaseBackup 
    @Databases = 'Lease',
    @Directory = N'\\wlsfs02\Shared05\DatabaseBackups',
    @BackupType = 'FULL',
    @Verify = 'Y',
    @CleanupTime = 360,
    @CleanupMode = 'AFTER_BACKUP',
    @Compress = 'Y',
    @ChangeBackupType= 'N',
    @CheckSum = 'Y',
    @LogToTable = 'Y'
" -b

When I run the job it errors out with:

Cannot Backup to Network Share using Ola Hallengren's Scripts

The file path does exist and is correct. If I change the file path to a local drive it will run and successfully backup the database. The job is running as:

Cannot Backup to Network Share using Ola Hallengren's Scripts

Looking at SQL Server Agent in SSCM it is using the Network Service account. If I try to change it to a domain account that has access to the network folder I get the following error:

Cannot Backup to Network Share using Ola Hallengren's Scripts

I know for sure the password I provided was correct.

What am I doing wrong? How do I get the script above to backup to a network location?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

The Agent service account is irrelevant.

You need to make sure that the database engine has relevant permissions. Either assign relevant permissions on the share to the Computer account in your domain, or change the service account for the database engine to a domain account and assign permissions to this account.

Use SQL Server Configuration Manager when you change service account. (Not using the right tool to change service account is why Agent didn’t start for you.)

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply