Solved

robocopy and windows 2008 r2

Posted on 2011-02-28
6
1,610 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
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Malli Boppe earned 250 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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now