Solved

window 8

Posted on 2016-09-12
14
22 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
Comment Utility
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
Comment Utility
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
Comment Utility
In your case use quarter marks
xcopy "D:\COMPANY PROJECT\*.*" "Z:\new backup" /S /E /C /Y
0
 
LVL 23

Expert Comment

by:NVIT
Comment Utility
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
Comment Utility
still not copy data request for alternate solution
0
 
LVL 9

Expert Comment

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

Author Comment

by:prana1984
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 9

Expert Comment

by:Tomas Valenta
Comment Utility
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
Comment Utility
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
Comment Utility
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 23

Expert Comment

by:NVIT
Comment Utility
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 23

Accepted Solution

by:
NVIT earned 250 total points (awarded by participants)
Comment Utility
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)
Comment Utility
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 23

Expert Comment

by:NVIT
Comment Utility
Question answered.
0

Featured Post

The curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Join & Write a Comment

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
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 enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

762 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

7 Experts available now in Live!

Get 1:1 Help Now