Discuss Backup in the Programming forum on Dev Hardware. Backup Programming forum discussing administration and coding scripts in languages including PHP, C++, C, Perl, Java, Visual Basic, XML, HTML, CGI, ActionScript, CSS, JavaScript, Fortran, BASH, and issues related to databases and even batch files.
Posts: 258
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
DOS Batch - Backup
I'm wanting to make a batch file that make's a backup of my important files. Is there a way for it to just overwrite files if they have been modified or if new one's have been created and delete files that have been deleted. I think the XCOPY command does it but I'm not sure. Or I could make it format the drive every time it does a backup.
When using /U does it update the files that are there and does it delete files that have been deleted. If it does then I don't think I wouldn't need to format.
Posts: 5,326
Time spent in forums: 1 Month 1 Week 2 Days 19 h 4 m
Reputation Power: 5341
It seems that you are wanting to maintain a mirrored directory. This means that the backup directory is an exact replica of the working directory. Files are copied to the backup whenever they are created or modified and they are removed from the backup if the original is deleted.
There is a great freeware program called Cobian Backup that works great for managing backups.
If you really want to do this yourself, you should look to WSH to do the job. The only way to manage this from Batch is to delete the contents of the folder and copy every file. This is fine is some environments, but larger directories can become very costly on system resources as well as being time consuming. Conversely, the WSH method will allow you to perform a more incremental-type backup where only changed files are handled.
__________________ Click the image if at any point you don't like my decision.
Posts: 258
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
Quote:
Originally Posted by Nilpo
It seems that you are wanting to maintain a mirrored directory. This means that the backup directory is an exact replica of the working directory. Files are copied to the backup whenever they are created or modified and they are removed from the backup if the original is deleted.
There is a great freeware program called Cobian Backup that works great for managing backups.
If you really want to do this yourself, you should look to WSH to do the job. The only way to manage this from Batch is to delete the contents of the folder and copy every file. This is fine is some environments, but larger directories can become very costly on system resources as well as being time consuming. Conversely, the WSH method will allow you to perform a more incremental-type backup where only changed files are handled.
Posts: 5,326
Time spent in forums: 1 Month 1 Week 2 Days 19 h 4 m
Reputation Power: 5341
I need a good article topic anyway. I'll put something together for you tonight to give you a good head start. Then we can tweak it to meet your exact needs.
Posts: 258
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
Thanks for the help Nilpo
Look's like theres alot you can do with WSH. I found this simple script on the web:
Code:
Set WshShell = WScript.CreateObject("WScript.Shell")
age = InputBox("Please type your age.")
newage = age + 5
WshShell.Popup "In 5 years, you will be " & newage & "."
Posts: 3,418
Time spent in forums: 2 Months 21 h 7 m 44 sec
Reputation Power: 3311
We sometimes use THIS at work for mirroring websites over the network ... it works great but it's not free. It will mirror an entire drive, just a folder, or any combination... it's pretty good.