Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old June 17th, 2008, 08:24 PM
tjb's Avatar
tjb tjb is offline
Contributing User
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Location: Oregon
Posts: 258 tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 3759 Folding Title: Novice Folder
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
Send a message via XFire to tjb
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.

I think this is what I want:
Code:
@Echo off 
Echo Formating Drive "Z"
format z:
cls

if NOT exist C:\\results\* mkdir C:\\results
if exist C:\\results\* goto start

:start
Echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>C:\results\backup.txt
Echo %Date% %Time% >>C:\results\backup.txt
Echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >>C:\results\backup.txt

ECHO ~~~~~~~~~~~~Important Data~~~~~~~~~~~~~~ >>C:\results\backup.txt
Echo Backing Up Important Data...
XCOPY "G:\My Documents\" "Z:\G\My Documents\" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "G:\My Pictures\" "Z:\G\My Pictures\" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "G:\Music\" "Z:\G\Music" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "C:\Documents and Settings\travis\Desktop\" "Z:\Desktop\" /E /C /V /H /U  >>C:\results\backup.txt
cls

Echo ~~~~~~~~~~~~Program's~~~~~~~~~~~~~~~~~~~ >>C:\results\backup.txt
Echo Backing Up Program's...
XCOPY "C:\Documents and Settings\travis\Application Data\foobar2000" "Z:\App Data\foobar" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "C:\Documents and Settings\travis\Application Data\Mozilla\Firefox" "Z:\App Data\Firefox" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "C:\Documents and Settings\travis\Application Data\Thunderbird" "Z:\App Data\Thunderbird" /E /C /V /H /U  >>C:\results\backup.txt
XCOPY "C:\Program Files\foobar2000 "Z:\Program Files\foobar2000" /E /C /V /H /U  >>C:\results\backup.txt
cls

msg * Backup Complete! Click OK to view log.
C:\results\backup.txt
cls
exit

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.
__________________
FOLD TO CURE!!!!    

Xfire    

My Computer    

Reply With Quote
  Trader Rating: 2 · #2  
Old June 17th, 2008, 10:59 PM
Nilpo's Avatar
Nilpo Nilpo is offline
Click here for more information.
 
Join Date: May 2004
Location: Salem, OH
Posts: 5,326 Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)  Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 Week 2 Days 19 h 4 m
Reputation Power: 5341
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
MySpace Orkut
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.

10011100011000101111100011100000011000000100000011 10010011011110110001101101011011110100011000001110 0100111101000100001

Visit Nilpo.com and Ask the Windows Guru!

Open me for some very useful links!    

Reply With Quote
  Trader Rating: 0 · #3  
Old June 18th, 2008, 12:00 AM
tjb's Avatar
tjb tjb is offline
Contributing User
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Location: Oregon
Posts: 258 tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 3759 Folding Title: Novice Folder
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
Send a message via XFire to tjb
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.
I'm going to look at WSH tomorrow. Thanks!

Reply With Quote
  Trader Rating: 2 · #4  
Old June 18th, 2008, 12:03 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Click here for more information.
 
Join Date: May 2004
Location: Salem, OH
Posts: 5,326 Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)  Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 Week 2 Days 19 h 4 m
Reputation Power: 5341
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
MySpace Orkut
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.

Reply With Quote
  Trader Rating: 0 · #5  
Old June 18th, 2008, 12:17 AM
tjb's Avatar
tjb tjb is offline
Contributing User
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Location: Oregon
Posts: 258 tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)tjb User rank is Second Lieutenant (5000 - 10000 Reputation Level)  Folding Points: 3759 Folding Title: Novice Folder
Time spent in forums: 6 Days 19 h 41 m 28 sec
Reputation Power: 69
Send a message via XFire to tjb
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 & "." 

Reply With Quote
  Trader Rating: 2 · #6  
Old June 18th, 2008, 12:25 AM
Nilpo's Avatar
Nilpo Nilpo is offline
Click here for more information.
 
Join Date: May 2004
Location: Salem, OH
Posts: 5,326 Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)Nilpo User rank is General 65th Grade (Above 100000 Reputation Level)  Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1Folding Points: 186994 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Month 1 Week 2 Days 19 h 4 m
Reputation Power: 5341
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
MySpace Orkut
There is a lot you can do. Check out my article feed!

Nilpo's Live Article Feed

Reply With Quote
  Trader Rating: 1 · #7  
Old June 21st, 2008, 01:57 PM
weevilofdoom's Avatar
weevilofdoom weevilofdoom is offline
BLURG
Dev Hardware Loyal (3000 - 3499 posts)
 
Join Date: Sep 2004
Location: Oregon
Posts: 3,418 weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 35th Grade (Above 100000 Reputation Level)  Folding Points: 32443 Folding Title: Starter FolderFolding Points: 32443 Folding Title: Starter Folder
Time spent in forums: 2 Months 21 h 7 m 44 sec
Reputation Power: 3311
Send a message via ICQ to weevilofdoom Send a message via AIM to weevilofdoom Send a message via MSN to weevilofdoom Send a message via Yahoo to weevilofdoom Send a message via Google Talk to weevilofdoom
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.
__________________

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > DOS Batch - Backup


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |