Go Back   PCMech Forums > Windows Support > Windows Tips, Tricks, and Tweaks

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-11-2006, 08:48 PM   #1
Member (10 bit)
 
rightcoast's Avatar
 
Join Date: Nov 2004
Posts: 800
Windows Backup Batch File

Here is one from work that someone might find useful. It saves some key data as an incremental backup, and makes a log for you.For anyone that didn't already know, it is a batch file, so save it in notepad with a .bat extention. You can of course schedule it to run at intervals or whatever, or just run it manually on occasion.
Code:
@echo off
cls
c:
cd\
:: *************************************************************************************
::								  BackUp Key Data.bat					8/10/06 Final
::							  Should be done Daily by user (sceduled)
::								 WINDOWS-XP & 2000 (TESTED)
::							XCOPY /switches SOURCE DESTINATION
::				  source Area   (My Documents) (Favorites) (Outlook) & User Specified
::				  Destination = Personal Network Drive  (P: at work)
::				  also creates/appends a log of these backups C:\bu-key.log
:: *************************************************************************************
echo
echo Starting back-Up of Key Files to Server >> C:\bu-key.log
echo Starting back-Up of Key Files to Server
echo First time could take a few minutes............
dir C:\bu-key.* >> c:\bu-key.log
::
::			YOU MUST CHECK EACH SOURCE AREA BEFORE RUNNING FIRST TIME
::			=========================================================
::
::								
echo Copying My Documents to Server
echo Copying My Documents to Server >> C:\bu-key.log
xcopy /s/i/v/d/r/Y "C:\My Documents" "P:\My Documents" >> c:\bu-key.log
if errorlevel 1 goto prob
::								 
:Fav
echo Copying My Favorites to Server
echo Copying My Favorites to Server >> C:\bu-key.log
xcopy /s/i/v/d/r/Y "C:\Documents and Settings\%username%\Favorites" "P:\Favorites" >> c:\bu-key.log
if errorlevel 1 goto prob
::								   
:Outlook
echo Copying My Outlook Data to Server
echo Copying My Outlook Data to Server >> C:\bu-key.log
xcopy /s/i/v/d/r/Y "c:\Documents and Settings\%username%\Local Settings\Application Data\Micsosoft\Outlook" "P:\Microsoft\Outlook" >> c:\bu-key.log
if errorlevel 1 goto prob
::
:ok
echo  Back-up of Your Key Files to Server Complete
echo  Back-up ....ok  >> c:\bu-key.log
goto end
:prob
cls
echo xcopy had a problem  >> c:\bu-key.log
echo Backup had a problem....Notify rightcoast at ext 1337 for help
echo - Don't call if the server is down.....
pause
pause 
goto end
:end
echo See Ya...
exit
::
::
:: /s = copies directories & subdirectories (except empty ones)
::
:: /i = if destination does not exist & coping more than 1 file that must be directory
::
:: /v = verify each new file
::
:: /r = overwrite read only files
::
:: /d = copy only new or updated files
::
:: /Y = SUPPRESSES PROMPTING TO CONFIRM YOU WANT TO OVERWRITE AN EXISTING DESTINATION FILE
::
::					  These are the errorlevel codes that XCOPY generates: 
::
::					  0 = Files were copied without error.  
::					  1 = No files were found to copy. 
::					  2 = The user pressed CTRL+C to terminate xcopy.  
::					  4 = Initialization error occurred. There is not enough memory 
::						  or disk space, or you entered an invalid drive name or 
::						  invalid syntax on the command line. 
::					  5 = Disk write error occurred.
You are going to want to change the P: drive location to wherever you want to backup to obviously, like your slave drive or own server. If you get an error I won't be at the specified extension. I'm lazy, and that was all I felt like changing to post it here. :P

The & user specified part refers to how I have to change it and add stuff for some people, for instance:
Code:
::								   
:notes
echo Copying My Lotus Notes to Server
echo Copying My Lotus Notes to Server >> C:\bu-key.log
Xcopy /s/i/v/d/r/Y "c:\Notes\Data\*.nsf" "P:\Notes\Data" >> c:\bu-key.log
if errorlevel 1 goto prob
So obviously you can add in whatever you require backed up.
rightcoast is offline   Reply With Quote
Old 08-13-2006, 11:01 AM   #2
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
Good script, I have one similar I run to backup our company files, just a few things to add though:

1. I do a full backup once a week and incremental backups nightly. You can copy just the files that changed that day using the "date" parameter of xcopy.

2. After the backup is completed you may want to compress the files since you probably will not be going to backup files very often. We have 25 gigs of data that compresses to around 7-8 gig. The utility I use is 7-Zip's command line tool.

3. To keep 3 weeks worth of backups and delete the old. I use a simple folder structure and the start of every weekly full backup goes like this:
a. delete week3 backups
b. move week2 backups to week3
c. move week1 backups to week2
d. backup current files to week1
This way you don't have to worry about backups consuming much space.
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:48 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2