Monday, February 1, 2010

Copying files on the network

Since i already tackled some batch file from my recent post. I will share some tips on copying/backing-up files on the network eventhough the files was in-use. It frustrates us sometimes when we are copying files on the network then at the middle of copy process it will stop and says “Can’t copy files.files because the file was in-use”. Grrrr… you are copying a 30G of file then suddenly it will error like this.

So you want to copy files without interruption? Ok! we will formulate one. This DOS commands will copy all file on your source folder, but if you have already the file on your target folder it will not. But if the old file on your source folder was modified or was updated this dos command will copy the updated files eventhough it is already present in your target folder.

1. Map the source computer and the target computer. Let say we put the target computer to drive x:\ and source to y:\. Of course you can use your local computer as your target and source too.

source computer/folder == Y:
target computer/folder == X:

2. Now ceate the batch file. Open your text pad or notepad and SAVE AS to copy.bat. Note: before clicking the SAVE button, it must be sure that the SAVE AS TYPE == ALL FILES and the ENCODING == ANSI

3. then create the script

@echo off
xcopy “y:\source folder\*.*” x:\target folder /c /s /r /d /i /h /y

rem back up successful!
pause

4. Save the file.
5. Close the batch file. Locate the batch file, then double click. [It must open the Command line interface and excute the script]. When the execution was finish, you must see the “back up successful!”.

6. Explaination here

@echo off ##

xcopy ## it will copy all the files and subdirectories

*.* ## it will copy all file with any extension. You can also select file according to extension like *.xls or according to files itself like reports.*

/c ## continue to copy even there is an error

/s ## copy directories and subdirectories except the empty one

/r ## overwrites read-only files

/d ## date

/i ## If destination does not exist and copying more than one file, assumes that destination must be a directory.

/h ## Copies hidden and system files

/y ## overwrite existing files

If you will use this for back up purposes. Let say you will backup a target folder every wednesday, you can schedule your back up using Windows Scheduler. START>PROGRAM>ACCESSORIES>SYSTEM TOOLS>SCHEDULED TASKS create new schedule and map to the bat file.

No comments:

Post a Comment