?
Solved

robocopy and windows 2008 r2

Posted on 2011-02-28
6
Medium Priority
?
1,654 Views
Last Modified: 2012-05-11
Hi,

I have been playing around with Windows 2008R2's built-in robocopy command line tool to handle by "file sync" from local machine onto a remote machine.

It all works fine, but I am confused as to how I would get a few other things to work..

Below is the command I am using:

robocopy "E:\SQL Backups\VAN-SQL02" "\\VAN-BACKUP\Automated Backup\VAN-SQL02" /E /COPY:DAT /DCOPY:T /MIR /V /NP /LOG:"E:\SQL Backups\BackupSync.log" /NDL /NC /TS /B /R:3 /W:60 /MT:3

Open in new window


I added the /NDL switch for No Directory List, but it still shows up in the log?

Also, is there a way to rotate the log file? Anyone have this working? I don't want to appent; but rather overwrite each time the back-up runs.. however I would like to preserve a set amount of logs (7 days or so).

This is used to move the local SQL backups (database and transaction logs), to a remote server which then is copied to tape.

One thing I would also like to experiment with is having the script run on a Windows Task Scheduler every 15 minutes, and sync any new changes to the source directory (which would be transactions that are backed up every 20 minutes by a stored procedure, and back-ups once a night).

Having the Scheduling Manager run on a 15 minute timer ensures me that the transaction logs are being moved off the server continuously and also the nightly back-ups.

Which robocopy option is best for that? /MOT:20 or ?

Finally, should would it be better to schedule two jobs and making use of /XF to exclude databases in one, and transactions in the other; so that they are discreet (transaction sync and backup sync).

Thanks for your help in this matter.
0
Comment
Question by:mirde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Malli Boppe earned 1000 total points
ID: 35004249
change the script as below so that a seperate log is generated every day.

rem      ### Set Date Format ###
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE /T') do set Date=%%c-%%b-%%a
set datenow=%date%
robocopy "E:\SQL Backups\VAN-SQL02" "\\VAN-BACKUP\Automated Backup\VAN-SQL02" /E /COPY:DAT /DCOPY:T /MIR /V /NP /LOG:E:\SQL Backups\%datenow%.log /NDL /NC /TS /B /R:3 /W:60 /MT:3

I wouldn't use /MOT switch but just schedule to run every 20 minutes.
I don't think you need 2 jobs one job should be fine.But I don't think you can copy the SQL databases through robocopy as if the file is in use the robocopy job fails.
0
 

Expert Comment

by:B2O
ID: 35005855
I too use a 'for' statement to grab today's date in order to write out log files in a similar manner.

If you want to clean logs up after 7 days, try the small resource kit tool 'forfiles.exe' with the following command:

>forfiles /p pathname /D -7 /c "cmd /c del /s /q @file"
0
 

Author Comment

by:mirde
ID: 35010011
mboppe,

Thanks for that I will try it, I am backing up the "backed-up" files of our SQL Server, I have a script that goes in and does the back-up; and places them in a directory; robocopy is used only to transfer the files to another server.

I could of used SQL SSIS to do this, but robocopy seems to have all the bells I need for the job.

The back-up files will not be locked, they only way I can see it fail is if robocopy tries to copy while back-up is in progress; in which case it will fail but succeed in the next run (20min).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mirde
ID: 35010044
mboppe, anyway to have a notification sent to the exchange server through the batch?
0
 
LVL 23

Expert Comment

by:Malli Boppe
ID: 35012432
These are the scripts that I am using.But need to make sure that the copy process finishes off on the same day.I mean to say uf you start the job on 02/03 it shoudl finish of on the same day.
Also you need to allow email relay for the server which is running the script.So in your case your SQL server should be able to relay emails.
ArchiveEmail.vbs
ArchiveEOM.txt
0
 

Author Closing Comment

by:mirde
ID: 35112603
Works just as I wanted it, thanks for your help.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…
This tutorial will walk an individual through the process of installing the necessary services and then configuring a Windows Server 2012 system as an iSCSI target. To install the necessary roles, go to Server Manager, and select Add Roles and Featu…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question