DaveWWW
asked on
Robocopy - Looking for help with syntax
I have a nightly backup of a folder to another PC. When a file cannot be copied, for example because it is open such as a .PST file, the destination .PST (from an earlier successful backup) is gone too.
I want RoboCopy to copy all new and changed files to the destination, leaving any other files in the destination alone. In xcopy syntax, I want this:
xcopy <folderA> <folderB> /s /e /y /c /d
In RoboCopy, I'm doing this:
Robocopy \\MachineA\Data C:\BackupFolder\Data /E /COPYALL /XO /R:0 /W:0 /LOG:c:\BackupLog1.txt
When outlook.pst on MachineA\Data is not available (because it is open, for example), the destination folder also doesn't seem to have the .PST, even though it was there the previous night.
Is there an obvious error I'm making here?
I want RoboCopy to copy all new and changed files to the destination, leaving any other files in the destination alone. In xcopy syntax, I want this:
xcopy <folderA> <folderB> /s /e /y /c /d
In RoboCopy, I'm doing this:
Robocopy \\MachineA\Data C:\BackupFolder\Data /E /COPYALL /XO /R:0 /W:0 /LOG:c:\BackupLog1.txt
When outlook.pst on MachineA\Data is not available (because it is open, for example), the destination folder also doesn't seem to have the .PST, even though it was there the previous night.
Is there an obvious error I'm making here?
I have found using the /Z and /B (or /ZB) allow the backup of files that are in use. This may circumvent your issue altogether
To close outlook remotely properly, you can make a .vbs script called by CloseOutlook.bat:
CloseOutlook.bat:
CloseOutlook.bat:
Set fn=CloseOutlook.vbs
>> echo "%fn%" Dim oOL
>> echo "%fn%" Set oOL = CreateObject ^("Outlook.Application"^)
>> echo "%fn%" oOL.Quit
cscript "%fn%"
Run it via psexec:Psexec \\machine -c CloseOutlook.bat
Robocopy can't copy in use files.
If you want to copy open files, you can enable VSS and use hobocopy. hobocopy will make use of the shadow copy to copy those files.
https://github.com/candera/hobocopy
Some basic instructions.
http://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/?PageSpeed=noscript
If you want to copy open files, you can enable VSS and use hobocopy. hobocopy will make use of the shadow copy to copy those files.
https://github.com/candera/hobocopy
Some basic instructions.
http://www.howtogeek.com/howto/windows-vista/backupcopy-files-that-are-in-use-or-locked-in-windows/?PageSpeed=noscript
ASKER
Hi all, and sorry for abandoning. I've been away, and am just back at this client today.
I understand you cannot copy in-use files, but the problem is that when (for example) a PST is in use, it doesn't copy it, *AND* it removes the old one from the destination.
What I can't figure out is why it seems to be removing the file from the destination. here is the line from the batch file:
Robocopy \\MachineA\Data C:\BackupFolder\Data /E /COPYALL /XO /R:0 /W:0
I'm thinking there must be something about /XO that I'm not understanding? I've looked in several users' Outlook folders on the backup drive, and the PST files are definitely not present. When I let the backup run overnight, they are there on the backup drive in the morning. I'm okay with missing the occasional backup, but not okay with Robocopy removing files.
I understand you cannot copy in-use files, but the problem is that when (for example) a PST is in use, it doesn't copy it, *AND* it removes the old one from the destination.
What I can't figure out is why it seems to be removing the file from the destination. here is the line from the batch file:
Robocopy \\MachineA\Data C:\BackupFolder\Data /E /COPYALL /XO /R:0 /W:0
I'm thinking there must be something about /XO that I'm not understanding? I've looked in several users' Outlook folders on the backup drive, and the PST files are definitely not present. When I let the backup run overnight, they are there on the backup drive in the morning. I'm okay with missing the occasional backup, but not okay with Robocopy removing files.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks very much. Although not the answer anyone wants, it is at least an answer. Now I know I'm not going crazy! :-)
Check the log file; the open files should be tagged with "newer" before the error message shows up.
Are you absolutely sure the command you posted here is the actual command you're running?
Is that part of a script, where maybe the target folder is cleared somewhere before the robocopy line?
Is that really the only task that does a copy to this folder (stranger things have happened than folders being backed up by multiple schedules ...)