We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

Want to create a back up

eteran
eteran asked
on
Medium Priority
181 Views
Last Modified: 2010-04-12
Hey is there away with the schudular task forme to set up a copy of a folder or drive to onther computer. if so how do I create the bath file to do this. and everynight in copyes it dose not append but it just writes over
Comment
Watch Question

click on start
click on run
type notepad
and click ok

Lets assume you want to copy the data from c:\my documents\important\ to c:\backups on the same PC.
Your commands are:

xcopy "c:\my doucments\important\*.*" c:\backups\*.* /s /y /d

The /s = include all subfolders
/y = do not prompt to overwrite files
/d =only  copy files that are NEWER in the source folder.

Save the file to the desktop or anywhere you want with the extension .bat or .cmd  (i.e. backupimportant.bat)
Double click it to test.
Open Scheduled Tasks, browse for the filename and add it.

If you know how to share folders and map drives between PCs, to backup to another PC:

xcopy "c:\my doucments\important\*.*" k:\backups\*.* /s /y /d
k:= any drive letter of another pc
Instead of k: you could also share the backups folder on the other pc and use \\sharename\*.* etc.

Author

Commented:
OKay now /d =only  copy files that are NEWER in the source folder.
Does this mean that if something was modifiede it will also copy it to the back up folder??

Yes, it will copy.
Once a program is modified, the date is changed to the date it was modified.

So, if I create a file called thisfile on  November 1, 2006 and add data to it on November 3, 2006, the date of the file is now 11/03/2006
By all means, test your batch file after you create it.

The first time you run it, all files should copy.
If you then run it again, immediately after, nothing will copy.

If you want to verify the copy every day, add the following lines to the xcopy line above

@echo off
cls
dir targetdrive:\targetfolder\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause

This will show you a list of the files copied, with the newest time and date files at the bottom of the list.

Author

Commented:
So step by step

1) open text file
2) paste xcopy "c:\my doucments\important\*.*" c:\backups\*.* /s /y /d
save it under .bat
and then doublke click it.

Is this it. I am new to this
You are correct.
Double click the icon on your desktop, that is...not the pasted text in Notepad.

Author

Commented:
What about echo off can you place in detail all the stuff it should have
I am new to these things
If you want to REVIEW the copy of files...use this:

xcopy "c:\my doucments\important\*.*" k:\backups\*.* /s /y /d
@echo off
cls
dir targetdrive:\targetfolder\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause


If you just want the copy to run and close use this:

xcopy "c:\my doucments\important\*.*" k:\backups\*.* /s /y /d

Remember the line above is an example of syntax.  You must use YOUR source and target folders.
Try it out.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
getting an error system can not find file


F:\promas*.*" x:\backups\*.* /s /y /d
@echo off
cls
dir X:\backups\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause

Author

Commented:
sorry this is the one I am running
F:\*.*" x:\*.* /s /y /d
@echo off
cls
dir x:\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
You have missed the xcopy command off first line...

xcopy F:\*.*" x:\*.* /s /y /d
@echo off
cls
dir x:\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause
Steve KnightIT Consultancy
CERTIFIED EXPERT

Commented:
Don't give me points for that btw, was just passing!!

Author

Commented:
Still getting the same error. FIle not found. F:\ is a local drive on the server and x is a mapped drive. Can this effect anything
Remove the " from first command line.
You only need the " if you have multiple words in your folder name

Make sure you have space between f:\*.* and x:\*.*

Author

Commented:
Hey this is the final code, thanks for the help.

xcopy F:\*.* x:\*.* /s /y /d
@echo off
cls
dir x:\*.* /od   (order by date oldest first)
echo Please note time and date of files above.
pause
Remove the info below from your file

(order by date oldest first)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.