SQL Server Performance

Copy Backup files Automatically

Discussion in 'ALL SQL SERVER QUESTIONS' started by gshyam23, Oct 23, 2012.

  1. gshyam23 New Member

    Hello Everyone,

    I got a requirement to copy the backup file from Production to some other shared folder on other machine automatically once the backup job is completed.
    Could some one please suggest me with any script which I can add to backup job to copy the latest backfile from the backup folder.

    I tried google on it and found script to copy specific file but I need to copy backup file which are less than 1 day old.(Because daily backup will create with time stamp)

    Really appreciate your help here.

    Thanks a lot in advance.

  2. Shehap MVP, MCTS, MCITP SQL Server

    For such cases, you can configure a job to run that T-SQL query below ,

    declare@cmdshellcmd varchar (4000)='xcopy /y C:\Source\Backup.txt C:\Destination'


    With considering the source and destination directories should be changed accordingly to yourenvironment

    But you have to enable first xp_cmdshell on your DB production serverusing the below query :

    EXECsp_configure'show advanced options',1




    EXECsp_configure'xp_cmdshell', 1




    Kindly let me know if any further help is needed

Share This Page