Transfer Backup

  • as mentioned earlier it will either be permissions or your UNC path is wrong. try typing your path into a start - run command and see if the folder opens your expecting

  • Yes folder is opening as expected

  • ok, its not permissions then.

    paste your copy syntax here that your using

  • declare @logid as int

    declare @backup_file as varchar(200)

    declare @neerav as varchar(200)

    --Select media_set_id of last backup

    set @logid=(select max(media_set_id) from

    msdb..backupmediafamily

    where physical_device_name like

    'D:\Testdatabase%')

    --Select exact backup device name if you create backup with maintenance plan and have different name for every backup

    set @backup_file=(select physical_device_name from msdb..backupmediafamily where media_set_id=@logid)

    set @neerav = 'copy'+' '+@backup_file+' '+'Z:'

    exec xp_cmdshell @neerav

    where z: is map network drive

  • try using the proper UNC path and not a mapped drive

  • Nero-1119276 (10/28/2009)


    declare @logid as int

    declare @backup_file as varchar(200)

    declare @neerav as varchar(200)

    --Select media_set_id of last backup

    set @logid=(select max(media_set_id) from

    msdb..backupmediafamily

    where physical_device_name like

    'D:\Testdatabase%')

    --Select exact backup device name if you create backup with maintenance plan and have different name for every backup

    set @backup_file=(select physical_device_name from msdb..backupmediafamily where media_set_id=@logid)

    set @neerav = 'copy'+' '+@backup_file+' '+'Z:'

    exec xp_cmdshell @neerav

    where z: is map network drive

    take the colon off your Z mapping.

    set @neerav = 'copy'+' '+@backup_file+' '+'Z'

  • Now access is denied but when i try with command prompt allows me to copy

  • access is denied to cmdshell or the drive location? are you still using the mapped drive or the UNC path?

    ps, note that xp_cmdshell will run under the sql server service account permissions so you have to

    a) make sure that user has access to the remote location as well

    b) if your still using the Z mapping you have to make sure the sql server service account sees the Z drive when you logon to the server as them

    you can set proxy accounts but lets stay away from that for now

  • when you copy file you are accessing remote location with credentials you are logged in with and when you use cmdshell you are accessing remote location with account that is starting sql server agent so this account need to have permissions on remote location

  • irena.bulatovic (10/28/2009)


    when you copy file you are accessing remote location with credentials you are logged in with and when you use cmdshell you are accessing remote location with account that is starting sql server agent so this account need to have permissions on remote location

    its not the agent, its the sql server service.

  • Animal Magic (10/28/2009)


    irena.bulatovic (10/28/2009)


    when you copy file you are accessing remote location with credentials you are logged in with and when you use cmdshell you are accessing remote location with account that is starting sql server agent so this account need to have permissions on remote location

    its not the agent, its the sql server service.

    Are you sure. I have sql 2000 and i don't know for 2005,2008 but i have different accounts for sql server and sql server agent and agent is running jobs so that account should have rights

  • irena.bulatovic (10/28/2009)


    Animal Magic (10/28/2009)


    irena.bulatovic (10/28/2009)


    when you copy file you are accessing remote location with credentials you are logged in with and when you use cmdshell you are accessing remote location with account that is starting sql server agent so this account need to have permissions on remote location

    its not the agent, its the sql server service.

    Are you sure. I have sql 2000 and i don't know for 2005,2008 but i have different accounts for sql server and sql server agent and agent is running jobs so that account should have rights

    ah ok, if its from within a sql job then yes it would use the agent service account. if you just run it in SSMS/EM then it will use the sql service account

Viewing 12 posts - 16 through 26 (of 26 total)

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