Hallengers script to Backup subfolders

  • Hi,

    I am wondering how can we use Ola Hallengren script to backup databases to sub folders. i.e. each database backup has to go each folder like we do using maintenance plan

    EXECUTE dbo.DatabaseBackup

    @databases = 'USER_DATABASES',

    @Directory = 'C:\Backup',

    @BackupType = 'FULL',

    @Compress = 'Y',

    @CleanupTime = 24

  • We um-and-ah about having a subfolder for each database.

    Whenever we need to port all the backups for all databases, and all log backups since the last FULL, to a different server having them all in one folder seems to make the job easier. But maybe there is a smart way to do that with sub-folders too.

    Apart from the massive number of files in the (single) folder I've never had a problem with all-in-one. I never go into the folder, manually, as a Restore is based on some APP working out which files are needed in order to make a restore - given some start-point and determining the appropriate FULL and any DIFFs & LOGs thereafter.

    All our backup file filenames start with the name of the database, so easy to do DIR MyDATABASE*.*

    Would be interested to hear of any advantage of sub folders though.

  • Ola's scripts create sub-folders by default.

    From the documentation: https://ola.hallengren.com/sql-server-backup.html

    DatabaseBackup creates a directory structure with server name, instance name, database name, and backup type under the backup root directory.

  • Yes. I can see that. It created a folder with instance name and sub folders with each db name.

    I gave path C:\backup and when I ran the job it created C:\backup\MYTest$Test\DB1 instead of that I want C:\backup\DB1. How can we do?

  • You will need to hack the script to remove the servername from the backup path.

  • Even the db backup is including the servername

  • Yes, again if you don't want that to happen, hack the script to remove it.

    Alternatively as your hacking the script, write your own script to backup the databases how you want them backing up.

    Personally I like having a folder with the servername and the file prefixed with the servername. Adds that level of security to my piece of mind when restoring databases, I know which server they have come from.

  • Thanks

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply