What are the challenges you face when working across database platforms? Take the survey

Network Copy to Multiple locations

olafdedigolafdedig Posts: 2
edited January 10, 2013 4:28AM in SQL Backup Previous Versions
I am using SQL back up 7 to do our backups, part of that is we use the copy to network location functionality. Is it possible to copy the backup to more than one location within the same backup task ? for example do backup then copy to location \\servername\dbbackups\ and the copy to \\otherservername\dbbackupsThanks


  • Options

    Yes it is possible to copy a backup to more than one location. You will need to edit the backup script, as this option is not available in the Back Up or Schedule Backup Jobs wizards. You can copy the script from the last step of the wizard, then edit and run it from SQL Server Management Studio.

    To copy a backup to another location, add COPYTO = '\\location\backups' to the WITH clause of the BACKUP command. You can include multiple COPYTO options to a BACKUP command. For example:
    execute master..sqlbackup '-sql "BACKUP DATABASE ''AdventureWorks'' TO DISK = ''c:\Backups\<AUTO>.sqb'' WITH COPYTO = ''\\servername\dbbackups'', COPYTO = ''\\otherservername\dbbackups'' " '

    The SQL Backup Agent service must have permission to write to the COPYTO locations.

    More information on the COPYTO option is available here: http://www.red-gate.com/supportcenter/Content/SQL_Backup/help/7.2/SBU_BACKUP_cmd

    I hope that helps.


    Marianne Crowder
    Red Gate Software Limited
  • Options
    Eddie DEddie D Posts: 1,791 Rose Gold 5
    Hi, thank you for your forum post.

    It is most definitely possible for SQL Backup to use multiple COPYTO parameters.

    However you cannot configure this using the wizards available through the SQL Backup GUI.

    If using the backup wizard you will need to script out the backup task to a new query window and manually add the second COPYTO comand. You can obtain the backup script in the last step of the Backup wizard via the script tab.

    Or if you wish to modify a scheduled backup job, open SSMS ->SQL Agent ->Jobs ->locate the job SQL backup created ->Right Click and select properties ->Steps->Edit the job step and manually add the second COPYTO command.

    Below, I have included Backup job syntax with two COPYTO parameters for reference, my example uses the code from a scheduled backup job:
    DECLARE @exitcode int
    DECLARE @sqlerrorcode int
    EXECUTE master..sqlbackup '-SQL "BACKUP DATABASE [AdventureWorks] TO DISK = ''E:\Backups\<AUTO>.sqb'' WITH FILEOPTIONS = 5, ERASEFILES = 2b, ERASEFILES_REMOTE = 5b, CHECKSUM, DISKRETRYINTERVAL = 30, DISKRETRYCOUNT = 10, COMPRESSION = 4, COPYTO = ''\\server1\CopyToFolder1'', COPYTO = ''\\Server2\CopyToFolder2'', INIT, THREADCOUNT = 3, VERIFY"', @exitcode OUT, @sqlerrorcode OUT
    IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)
    RAISERROR ('SQL Backup failed with exit code: %d  SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)

    I hope the above answers your question.

    Many Thanks
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
Sign In or Register to comment.