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
Solved

window 8

Posted on 2016-09-12
14
39 Views
Last Modified: 2016-10-02
dear sir,
we need to one batch file via this we can sync folders to our network drive every three hours for backup purpose
0
Comment
Question by:prana1984
  • 6
  • 4
  • 4
14 Comments
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 41793804
Open notepad and paste the following command:
xcopy c:\FolderToSync\*.* x:\PathForBackup /S /E /C /Y
Change your source (c:\FolderToSync\*.*) and destination (x:\PathForBackup) to real names in your environment and save the file like sync.cmd.
This script will copy files and subfolder in source to the destination and will not stop in case of error and suppress warning about rewriting the destination file so in the target path will be always latest data.
For this script create task in scheduler and run it in period you wants.
0
 

Author Comment

by:prana1984
ID: 41793812
dear sir i have created and try to manual run but not data copy
xcopy D:\COMPANY PROJECT\*.* Z:\new backup /S /E /C /Y

source path             D:\COMPANY PROJECT
destination path     Z:\new backup (network drive)
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 41793820
In your case use quarter marks
xcopy "D:\COMPANY PROJECT\*.*" "Z:\new backup" /S /E /C /Y
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 24

Expert Comment

by:NVIT
ID: 41793844
If you want, in subsequent scheduled runs,  the sync to include files that may have been deleted from source, which xcopy does not do, you should use Robocopy instead. With the /MIR switch. E.g.

robocopy /mir /dcopy:t /e "D:\COMPANY PROJECT\*.*" "Z:\new backup"

Open in new window


/mir makes an exact copy of source.

/dcopy:t copies the datestamps of folders. Else the current date is used.

/e copies sub folders, including empty ones. If you just want non empty folders, use the /s switch.
0
 

Author Comment

by:prana1984
ID: 41793961
still not copy data request for alternate solution
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 41793970
can you provide me the error you received by running the command, please ?
0
 

Author Comment

by:prana1984
ID: 41793986
dear sir
i have created batch file and just click to on this batch file its running and close within second so how to analyses error
i am very thankful of u if u help me to resolve this issue .
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 41793991
Open command prompt by clicking on Start button and typing cmd.exe.
It opens separate window where you can paste (by mouse right click and paste)
the command and run it by pressing Enter. The result is written to the same window.
0
 

Author Comment

by:prana1984
ID: 41794055
error is below

icrosoft Windows [Version 6.1.7601]
opyright (c) 2009 Microsoft Corporation.  All rights reserved.

:\Users\3524>robocopy /mir /dcopy:t /e "D:\COMPANY PROJECT\*.*" "Z:\new backup

------------------------------------------------------------------------------
  ROBOCOPY     ::     Robust File Copy for Windows

------------------------------------------------------------------------------

 Started : Mon Sep 12 17:54:39 2016

  Source -
    Dest -

   Files :
 Options : /S /E /COPY:DAT /DCOPY:T /PURGE /MIR /R:1000000 /W:30

-----------------------------------------------------------------------------

RROR : Invalid Parameter #4 : "D:\COMPANY PROJECT\*.*"

      Simple Usage :: ROBOCOPY source destination /MIR

            source :: Source Directory (drive:\path or \\server\share\path).
       destination :: Destination Dir  (drive:\path or \\server\share\path).
              /MIR :: Mirror a complete directory tree.

   For more usage information run ROBOCOPY /?


***  /MIR can DELETE files as well as copy them !
0
 
LVL 9

Expert Comment

by:Tomas Valenta
ID: 41794064
OK. I think result of xcopy command I sent you at the start of this topic.
In robocopy command you need to change it:
robocopy /mir /dcopy:t /e "D:\COMPANY PROJECT" "Z:\new backup
0
 
LVL 24

Expert Comment

by:NVIT
ID: 41794256
Sorry for my wrong post, Prana.
Thanks for the help, Tomas.

Not sure if this matters but, you may need to add the closing quote for the destination. I.e.

robocopy /mir /dcopy:t /e "D:\COMPANY PROJECT" "Z:\new backup"
0
 
LVL 24

Accepted Solution

by:
NVIT earned 250 total points (awarded by participants)
ID: 41794274
I would add the /R and /W switches from /R:1 /W:1
Else, you may  be waiting too long  if it reaches a problem file.

robocopy /mir /dcopy:t /e /w:1 /r:1 "D:\COMPANY PROJECT" "Z:\new backup"
0
 
LVL 9

Assisted Solution

by:Tomas Valenta
Tomas Valenta earned 250 total points (awarded by participants)
ID: 41795552
Prana, but there is general question. Do you need to have only 3 hours backup files back ? Because robocopy with /MIR switch make exact copy of your folder but when you delete file on local drive the robocopy delete this file also in backup. Maybe better should be to make decision how long back you want to be able to restore data and then to change the backup script to meet your requirements:
Here is example:
SET FromPath=d:\COMPANY PROJECT\*.*
SET BackPath=Z:\new backup\
SET LogPath=Z:\LOGS\
For /f "tokens=2-4 delims=/. " %%a in ('date /t') do (set ArchiveFolderDate=%%c-%%b-%%a)
For /f "tokens=1-2 delims=: " %%a in ('time /t') do (set ArchiveFolderTime=%%a.%%b)
set ArchiveFolderName=%ArchiveFolderDate%-%ArchiveFolderTime%
echo %ArchiveFolderName%
xcopy %FromPath% %BackPath%%ArchiveFolderName%\ /S /E /C /Y

This script creates subfolder in Z:\new backup\ based on current date and time. So every backup creates separate snapshots of COMPANY Projects folder. The folder name depends data and time international settings on your computers so it must be tuned. If you give me back result of the following commands I can change the script:
date /t
time /t
0
 
LVL 24

Expert Comment

by:NVIT
ID: 41825214
Question answered.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article explains how to install and use the NTBackup utility that comes with Windows Server.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

792 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