Examples of Windows batch file for copying backups?

  • Hey guys,

    I would like to have a simple batch file that will copy over all local backups from a folder(s) on the source server over to a network share folder(s).

    Does anyone have something like this, or a close example?

    Thank you.

  • Try XCOPY:

    XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...]

    Or simpler:

    xcopy /e /v /y d:\Backups\files \\NTSERVER\backups\data

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle

  • I recommend using xcopy. We have several bat files to do similiar things.

    you would put something like the below in a bat file.

    There are many options with xcopy and I would recommend doing some research on it.

    xcopy \\servername\sharename\foldername \\destination\share\folder /y

    Dan

    If only I could snap my figures and have all the correct indexes apear and the buffer clean and.... Start day dream here.

  • Copy is a good option, I personally use Robocopy that offer some good features.

    Includes purging old files..

    http://technet.microsoft.com/en-us/library/cc733145%28WS.10%29.aspx

  • Great, xcopy does the trick.

    Do any of you guys have a script for purging the old backups?

  • I believe this only only works on local drives, not UNC paths.

    EXEC xp_cmdshell 'FORFILES /p F:\Backup /s /m *.bak /d -3 /c "CMD /C del /Q /F @FILE"'

    Also see this http://qa.sqlservercentral.com/scripts/Administration/62729/

Viewing 6 posts - 1 through 5 (of 5 total)

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