I have a mdb file at C:\Program Files\ApplcationName\filename.mdb. Please let me know the COPY command to take a backup using .bat file to a folder C:\Backup. In short i am having probles because of the space between "Program" and "Files".
Thanks jaz
The filename portion of the backup is the worst part to create. You need to be able to create a new file everyday without too much hassle. So here's what I use:
If you combine two of these answers (mine and a previous one) you get this gem:
Doing it this way will give you a file for ever day its run, named with the date.
A complete backup script would look like this
This is a complete interactive solution. But the real power is in the
set mydate
line. Being able to slice a string is a forgotten art in DOS;I take the command output of date, then cut it up, and spit out something that can be used as a filename. That way a new file is created everyday, and you can have a "real" backup system.
Just edit the servernames, DC1, FS1, EXCH and put in your own, or just use drive paths.
I haven't worked with windows in a long time but:
You may want to look up the online help about the switches you want to use for copying.
You probably want to use robocopy or xcopy instead of copy. They're both much more robust.
The issue with spaces can be resolved by enclosing the path in quotes. For instance, "%ProgramFiles%\ApplicationName\filename.mdb" will work. The command I would use is:
when you get to a directory with spaces, just use quotes.
copy c:\"two words"\"another one"\FileIcareabout.bla c:\backup\FileIcareabout.bla
or put each path in quotes...
copy "c:\two words\another one\FileIcareabout.bla" c:\backup\FileIcareabout.bla
TEST from a command line with test files before you setup the job!
The reason that you are having issues is because you need to put quotes around any filename or path with spaces. Use the at command to get the file to backup on a scheduled basis. See Command-line reference
in this case if you want the backup to occur at 11pm every day the line would be: