Real good idea. To make it simpler with no batch files
Create a Briefcase in the destination location and drag the folders / files to be backed up (this is only the first time). Use Task Skeduler to open the Briefcase which automatically checks for changes and asks user to update which is just one click to update.
Is there a switch to avoid this user interaction.
Discussion on:
View:
Show:
To make the logfile more manageable add the following commands before the xcopy to the batch file:
date /T >> c:\filename.txt
time /T >> c:\filename.txt
date /T >> c:\filename.txt
time /T >> c:\filename.txt
Win98/se does not recognize the /T switch on the DATE and TIME commands, nor did Win95. (I'll have to try it with ME, NT, 2K & XP to see which do.)
I use the following trick to add the date and time to the log file:
ECHO. | DATE | FIND "Current" >> backup.log
ECHO. | DATE | FIND "Current" >> backup.log
The period after ECHO is very necessary! It provides a which is piped to DATE or TIME to satisfy the prompt for a new value. The FIND command will filter out the prompt line. Note that the FIND text is case sensitive!
This adds two lines to the log file which look like:
Current date is Mon 07-15-2002
Current time is 11:05:22.34a
I use the following trick to add the date and time to the log file:
ECHO. | DATE | FIND "Current" >> backup.log
ECHO. | DATE | FIND "Current" >> backup.log
The period after ECHO is very necessary! It provides a which is piped to DATE or TIME to satisfy the prompt for a new value. The FIND command will filter out the prompt line. Note that the FIND text is case sensitive!
This adds two lines to the log file which look like:
Current date is Mon 07-15-2002
Current time is 11:05:22.34a
I would recommend keeping a number of log files, as they help troubleshoot backup problems. Also, if you add a time stamp before and after running the xcopy command, then you can see if the backup is taking an unusual amount of time. Here's the code:
echo Starting Daily Backup
del "C:\Backup Logs\backuplog5.txt"
rename "C:\Backup Logs\backuplog4.txt" backuplog5.txt
rename "C:\Backup Logs\backuplog3.txt" backuplog4.txt
rename "C:\Backup Logs\backuplog2.txt" backuplog3.txt
rename "C:\Backup Logs\backuplog.txt" backuplog2.txt
echo Daily Backup >> "C:\Backup Logs\backuplog.txt"
date /T >> "C:\Backup Logs\backuplog.txt"
time /T >> "C:\Backup Logs\backuplog.txt"
echo ================== >> "C:\Backup Logs\backuplog.txt"
xcopy /d/y/e/v/f/h/k/z "C:\Documents and Settings" "\\Server\Backups" >> "C:\Backup Logs\backuplog.txt"
echo ================== >> "C:\Backup Logs\backuplog.txt"
date /T >> "C:\Backup Logs\backuplog.txt"
time /T >> "C:\Backup Logs\backuplog.txt"
echo Starting Daily Backup
del "C:\Backup Logs\backuplog5.txt"
rename "C:\Backup Logs\backuplog4.txt" backuplog5.txt
rename "C:\Backup Logs\backuplog3.txt" backuplog4.txt
rename "C:\Backup Logs\backuplog2.txt" backuplog3.txt
rename "C:\Backup Logs\backuplog.txt" backuplog2.txt
echo Daily Backup >> "C:\Backup Logs\backuplog.txt"
date /T >> "C:\Backup Logs\backuplog.txt"
time /T >> "C:\Backup Logs\backuplog.txt"
echo ================== >> "C:\Backup Logs\backuplog.txt"
xcopy /d/y/e/v/f/h/k/z "C:\Documents and Settings" "\\Server\Backups" >> "C:\Backup Logs\backuplog.txt"
echo ================== >> "C:\Backup Logs\backuplog.txt"
date /T >> "C:\Backup Logs\backuplog.txt"
time /T >> "C:\Backup Logs\backuplog.txt"
Andrew - I like your method. I've build this command file on my C root directory as a .COM file (hope that's right!) but when I execute it it gives a window "This program has performed an illegal operation and will be terminated etc....
So when I go back to DOS and execute each command line independently they all work until I try to redirect the 'date' output via the '>>' then it hangs in DOS and when I look at the resulting log the message reads:
Invalid date
Enter new date (mm-dd-yy):
end of message. It looks as though it's taking the '/T' as an input date. How do I do this redirection and switch recognition thing and is it valid to name the file as backupmyfiles.com?
Thanks,
Bob
bbbbobber@yahoo.com
So when I go back to DOS and execute each command line independently they all work until I try to redirect the 'date' output via the '>>' then it hangs in DOS and when I look at the resulting log the message reads:
Invalid date
Enter new date (mm-dd-yy):
end of message. It looks as though it's taking the '/T' as an input date. How do I do this redirection and switch recognition thing and is it valid to name the file as backupmyfiles.com?
Thanks,
Bob
bbbbobber@yahoo.com
A short ,simple,and highly effective solution for a problem that plagues us all.If only my network were like this...;)
Thanks alot!!!
Thanks alot!!!
is there a way to modify the sample code to scip a certain subdirectory in the "my documents" folder?
Xcopy has a /exclude flag against which you can list files or directories. Run xcopy /? at command prompt t see all flags. I think you can get it to read a text file containing a lit of excludes, try exclude:exclude.txt
I work in an area that states; "Less user intervention is the best."
I use the Briefcase for travel.
Dan
I use the Briefcase for travel.
Dan
I wrote File Stager (http://members.cox.net/jcpratt2/) to put a Windows UI on the type of batch files people have been writing for years to copy files. It sorts files, copies or moves them, and can be used for backup operations. I use it every dayat work and home, including copying hundreds of files to a CD-R (Windows blows up because it can't handle more than about 600 files in a single copy operation). It also does most of what RoboCopy does, including 2-way syncing of folders, and you don't need to buy the NT resource kit or have NT to use File Stager. Its shareware, so you can try it for free for 30 days. Its $15 for one license if you want to keep it. It runs on Win 9x, NT, 2000, and Citrix, and I haven't heard any complaints about WinXP.
Just another idea for everyone. 3 or so years ago I bought a copy of Centered Systems' Second Copy -- 2002 winner of the People's Choice Award for Best Overall Utility for third year in a row -- and have been using it ever since. I schedule documetn backups to go across my intranet every 30 minutes, so that updates to documents and other important files are mirrored on another workstation or server on a regular basis. I do it this way ever since the one day when I lost my machine around 3PM due to a power outage, and the entire's days work - including a 45-page document that I had just about completed typing - was lost in an instant.
See www.centered.com for more info. I do not own the company, nor do I know the principles - I just like their program, and highly recommend it.
See www.centered.com for more info. I do not own the company, nor do I know the principles - I just like their program, and highly recommend it.
The backup worked fine, except for my backup.pst file that I did for Outlook 2000.
The message said "File creation error - The specified file could not be encrypted."
WHY????
The message said "File creation error - The specified file could not be encrypted."
WHY????
Even though we have all of our users storing files on a server and that drive is mirrored, we're still exposed to a hard disk failure on the server, however remote a complete failure is. Since there are typically vast unused hard disk resources scattered around a network, an excellent use of XCOPY is to copy the critical data files of users across the network to some backwater disk with space to spare.
We back up the common user directories on our server every night to an offsite machine connected by WAN. We use the same switches mentioned in the article, with the addition of /O, /K, /H, and /E.
The /O causes file ownership and ACL information to be copied.
/K copies file attributes. Normal XCOPY will reset read-only attributes.
/H copies hidden and system files.
/E copies directories and subdirectories, which saves on scripting and allows users to create new subdirectories as needed and assures that they are backed up along with all their other files.
Thanks for the article! Very good.
We back up the common user directories on our server every night to an offsite machine connected by WAN. We use the same switches mentioned in the article, with the addition of /O, /K, /H, and /E.
The /O causes file ownership and ACL information to be copied.
/K copies file attributes. Normal XCOPY will reset read-only attributes.
/H copies hidden and system files.
/E copies directories and subdirectories, which saves on scripting and allows users to create new subdirectories as needed and assures that they are backed up along with all their other files.
Thanks for the article! Very good.
You can use a 3rd party tool, such as RAR, or Winzip, to backup the files to the network, thus saving a considerable amount of space on the server. I use the user's login name from the Enviroment variable in my batchfile, with a pre-configured standard list of files to backup specified also on the command line. E.g. using RAR.EXE:
rar u -r H:\backup\%LOGIN% !list.txt
This updates the archive named after the user with the files specified in the list.txt file.
To use this, users simply press a button in their Lotus Notes, but, you can make a generic shortcut on the desktop as well. The FIRST time may take long, but from then on the -u parameter just does Updates.
if they need something, they can just pull the file from the Archive.
rar u -r H:\backup\%LOGIN% !list.txt
This updates the archive named after the user with the files specified in the list.txt file.
To use this, users simply press a button in their Lotus Notes, but, you can make a generic shortcut on the desktop as well. The FIRST time may take long, but from then on the -u parameter just does Updates.
if they need something, they can just pull the file from the Archive.
At home, where I have two hard drives, I use the DOS version of PKZIP to do roughly the same thing. On boot-up my batch file deletes BK5, then 'moves' BK4 to BK5, 3 to 4, 2 to 3, 1 to 2, then 'copies' the ZIP to BK1, then 'zips' the specified directories and a few individual files to the ZIP file. Of course the ZIP file of one drive is stored on the opposite drive (C: on D:, D: on C:). After you have run the backup batch file once, add the -f (freshen) switch to the PKZIP command and from that point on only new or changed files will be added or updated in the target ZIP file. The above will give you 6 full backups of the specified directories and/or files.
I like the idea of creating a batch file to backup files. I've been wanting to create this for quite some time but never got around to it. I'd also like to create a batch program to backup my registry after I make manual changes to it. I realize Windows backs it up every time it starts, but I'd like to run this manually so that it backs up to a folder I prefer.
Any ideas? - I would like to do this for my work and home machines. At work, I used Win2000 on a network. At home, Win98 SE, noton a network.
Thanks in advance.
Thomas
Any ideas? - I would like to do this for my work and home machines. At work, I used Win2000 on a network. At home, Win98 SE, noton a network.
Thanks in advance.
Thomas
Hi,
I tried to do the scheduling task, somehow it does not work or i am making some error.
what i did as follows:
write the code in notepad,
Next made a folder in d drive(which is a removable hd connected to the pc with a usb cable)
then did the scheduling.Is there something else to do.
NB what do u mean to copy it out of the way location of the users hd. I have it on the desktop.
Best wishes and waiting for an answer.
Thank u
mna
I tried to do the scheduling task, somehow it does not work or i am making some error.
what i did as follows:
write the code in notepad,
Next made a folder in d drive(which is a removable hd connected to the pc with a usb cable)
then did the scheduling.Is there something else to do.
NB what do u mean to copy it out of the way location of the users hd. I have it on the desktop.
Best wishes and waiting for an answer.
Thank u
mna
I use a program called 'BATCHRUN' from Outer Technologies to copy files in case they get deleted.
http://www.outertech.com
It's a free program
http://www.outertech.com
It's a free program
I've done something very similar for one of our sales VP's, but with a twist. He keeps every email he ever received, 'just in case'. His outlook pst file is several hundred MB. I used the command line options of Winzip 8 to compress all his files into one backup file. It takes less time to copy and he doesn't accidently work on a backup copy.
Dave B
IT Manager
Dave B
IT Manager
Hi,
I just want to know that how can I copy the files from user machine to server using automatically user id & password when running the batch file.
If there is any option to using the user id & password to log on the server in a special folder then how can we code this in the batch file to run.
Awaiting any idea/help.
Thanks / Sulman
I just want to know that how can I copy the files from user machine to server using automatically user id & password when running the batch file.
If there is any option to using the user id & password to log on the server in a special folder then how can we code this in the batch file to run.
Awaiting any idea/help.
Thanks / Sulman
use the "net use" commands to map a network drive first. You can set username and password in the command. At a command prompt type "net help use " to get the syntax.
Under good security protocols...user passwords should be changed frequently. Also having a password in a batch file where it could be read by someone is not good.
If a users password never changes and the batch file never needs modifying, I wouldfind a batch file compliler that would convert the batchfile to an exe file.
Michael Welch
If a users password never changes and the batch file never needs modifying, I wouldfind a batch file compliler that would convert the batchfile to an exe file.
Michael Welch
We have this set up on my win98se station. I've set up the schedule for every day. It would look like it was working - but when I checked the backup file - they had not been updated. If I do the backup manually - it works perfectly. Any suggestions?
The modified dates displayed in Win98se do not reflect the date the file was copied. It reflects the date the file was actually modified. If you change a file on 7/1/02, and copy it somewhere on 7/3/02, the modified date will remain 7/1/02.
The XCopy seems to be working as the daily task runs but when I check the backed up files its not there, though it works manually. Any suggestions?
I had a similar problem with a win2000 machine. I assumed that if you didn't want a password for the scheduled task, you could just leave it blank.....The manual run of the batch file still works fine, but when the task scheduler goes to run the file, if you do not have an existing username and password entered for the task, the scheduled task will not run because of insufficient security rights.
If, you have set up a scheduled taks with the domain user's username and password to run and the user's password changes, it will no longer work (i.e. backups using the user's name and password to copy to a network share). The scheduled task servicewill not update to reflect this change. Anyone know how to schedule a task using this application to run within the command prompt, and use the current logged on user's username and password - as if I click a batch file manually? Or know how to ensure the service username and password changes to refelect that changed on our domain every X days for each user?
How would you modify the batch file code to back up multiple select files only from a specific directory? Would it be a separate line command for each file, or can you join the filenames together in one long command line?
This batch file with auto scheduling allows one to have retrievable file without any hassle. How many of us really backup everyday? This way the file you deem important get backed up automatically! Thanks for the wonderful idea.
Good article and idea. Thanks.
After reading it and the posts, I tinkered with my Win2k box by doing the followig:
Add a Value to:
HKLM\Sotware\Microsoft\Windows\Run\
Value Name: LocalBackup
Data Type: REG_SZ
String: "C:\path to batch file\backup.bat
This tested fine. I like this better than the Task scheduler since my users sometimes power their machines off early etc. I like the idea of the process happening at PC startup.
After reading it and the posts, I tinkered with my Win2k box by doing the followig:
Add a Value to:
HKLM\Sotware\Microsoft\Windows\Run\
Value Name: LocalBackup
Data Type: REG_SZ
String: "C:\path to batch file\backup.bat
This tested fine. I like this better than the Task scheduler since my users sometimes power their machines off early etc. I like the idea of the process happening at PC startup.
I like this suggestion, I have been using a shortcut in the Startup folder to automatically perform an xcopy backup to a network drive when a user starts their machine.
How about those users who did not turn off their computers? What happen to his/her daily important files? Yours is different from others.
I put a shortcut on the users desktop but it wouldn't hurt to add it to RUN in the registry as well. Nice idea
Create a userbackup2.bat file that uses the /m switch in the xcopy command and schedule it to run during the day. This way it only selects changed files and exits quicker if the backup was done in the registry.
The /m switch will turn off the archive bit after a successful copy.
In the userbackup1.bat file you could even specify to turn all the archive bits on certain files or globably by adding the attrib command. This of course would depend on your backup strategy.
Michael Welch
The /m switch will turn off the archive bit after a successful copy.
In the userbackup1.bat file you could even specify to turn all the archive bits on certain files or globably by adding the attrib command. This of course would depend on your backup strategy.
Michael Welch
It would be better to have the backup start on shutdown, so backing up all changes and new files
before switching off. In my experience PC tend to go faulty on power on. If you waited to Backup on start up and it didn't, you would have lost a whole days data.This should be done in the reg if I knew how
before switching off. In my experience PC tend to go faulty on power on. If you waited to Backup on start up and it didn't, you would have lost a whole days data.This should be done in the reg if I knew how
I would like to know if there is a way to make the batch file run at shut down instead of start up that would be the most logical solution since most of my users tell it to shut down, turn off the monitor and leave.. plus if something is wrong with the machine it may or may not reboot in the morning, IE the user installed software yes we allow that, or the new video drivers are incompatible you know all the "little" things that make life fun.
I've long used XCOPY at home for just this purpose. Even though I have a network, I opted for a different technique:
I have several CDRW disks I use for backing up selected areas of my computer. On each disk is a batch file that uses XCOPY to do the job. The nifty part is that I have an AUTORUN.INF file on each disk. This is a text file containing:
[autorun]
open=backup.bat
icon=whatever.ico
After a long night of coding, I can grab the CDRW labelled 'CODE' and insert it into my CD burner and go to bed. The backup batch auto-starts and backs up the selected areas automatically. Now if I can just figure out how to get it to change disks automatically ...
I have several CDRW disks I use for backing up selected areas of my computer. On each disk is a batch file that uses XCOPY to do the job. The nifty part is that I have an AUTORUN.INF file on each disk. This is a text file containing:
[autorun]
open=backup.bat
icon=whatever.ico
After a long night of coding, I can grab the CDRW labelled 'CODE' and insert it into my CD burner and go to bed. The backup batch auto-starts and backs up the selected areas automatically. Now if I can just figure out how to get it to change disks automatically ...
You could buy another burner. To bad Nakimichi didn't continue their multi CD-Rom line to include a burner. That would be something.
Autorun is a nice tweak, I use Xcopy routines for my very small business clients who backup to CD-RW from an icon I put on their desktop. With your suggestions they can just bung the CD in.
Cheers
Guy Fordy
4D Consulting - independent IT support& advice for small business
Cheers
Guy Fordy
4D Consulting - independent IT support& advice for small business
gdunger's suggestion is the perfect solution to a problem I have.
Could somone explain how to get the batch file to backup to the CDRW drive.
The PC in question runs Win XP, I have no problem with identifing the files that need to be backed up only the integration of the CD burner into the batch file.
Thanks
Could somone explain how to get the batch file to backup to the CDRW drive.
The PC in question runs Win XP, I have no problem with identifing the files that need to be backed up only the integration of the CD burner into the batch file.
Thanks
You should be able to format a CDRW to do direct read and write just like a hard drive. Roxio and Adaptec call it DirectCD. Note-this is using a CDRW disc and not a CDR disc. The prob is you have to keep an eye on disc free space and/or overwrite files with each backup.
While copying to a different folder on the same disk provides protection from accidental deletion, it does not protect from disk failure. A better solution is to use a different disk, either internal or external, as the target.
If the quantity of data is small, a removable disk works well. I use a Zip drive in this manner. Removable disks also have the advantage of allowing multiple copies.
If the quantity of data is small, a removable disk works well. I use a Zip drive in this manner. Removable disks also have the advantage of allowing multiple copies.
This artical came at a time when I needed this exact batch file. Only I modified it to copy to a zip 250 as well as a networked drive.
- Keyboard Shortcuts:
- Prev
- Next
- Toggle









































