echo off set test= rem ---- Set test=echo to test this batch file cls echo *** echo *** echo *** goto start Backup Documentation Version 1.01: University of Northern Iowa Last Updated: March 20, 2006 By Tom Peterson Backup Solution Criterion • Automated backup procedures • Full Backup when desired (recommend automated to weekly Wednesday after end of workday) • Backup incrementally daily or at any time user desires (recommend time after end of workday except Wednesday when the Full Backup is taken) • Provide for convenient user level restore without using central administrator resources • Capability to restart backup routine anytime to minimized accumulated size of backup file • Utilize server backups (recommended to occur on Wednesdays during workday hours) for tertiary archival plus additional disaster recovery capability • User’s controlled to designate and subsequently modify what PC files are to be backed up Solution/Methodology 1) Utilize Windows Backup Utility to: a. Create/Modify the backup file set (Backup.bks) b. Perform backup to user’s network drive (***Note***: When the User’s Windows password change occurs the backup jobs password must be manually reset to synchronize otherwise the backup job will fail without providing any notice, we hope to add this reminder to the Windows expiration notice message) 2) Create Batch command file options for: a. Full Backup to start/restart accumulating periodic (weekly) backup file b. Incremental Backup to add daily changes to accumulating backup file c. Keephistory option to additionally maintain the previous accumulation as a history file (***Note***: this option is only recommend for the most sensitive situations when frequent restores are anticipated) d. Automate to utilize Windows Schedule Task capability for full and incremental backups Documentation: This batch file is design for use backing up the user desired data from a Windows XP personal computer to a network server drive of the individual Windows user. (The backup file could be placed on the same PC but this does not provide for disaster in case of hard drive failure. If the backup file target location file structure is FAT the limitation of backup is 4-GigaBytes accumulated file size.) The additional assumption is that this backup file will be archived to a tape backup system providing tertiary backup and disaster recovery capability. The backup file contained on the network drive or server enables the user to restore files to any given day since the last full backup was performed. The tape backup archives may be also be requested for restoration (by network staff) should the need arise which means you have the possibility to restore files even further back into the past. The backup routine begins will a full normal backup (parameter “full” or "keephistory") then daily incremental backups (parameter “incremental”) are appended to the initial full backup file. What files are targeted for backup is the responsibility of the each PC user and is setup by using the Windows Backup Program (Start/AllPrograms/Accessories/SystemTools/Backup). The “whattobackup” parameter provides the filename which contains information designating what files should be backed up. This file is created by using the Windows Backup Program (default file recommendation is “My Documents\Backup Job\Backup.bks”). This file is intentionally placed so that this file is included in the backup routine so that it can also be recovered if necessary. The Windows Backup Program allows you to make changes to this file should you want to subsequently include or exclude files or directories. The “wheretobackup” parameter specifies the output backup file location and name (default file is "%backuppath%\Backup.bkf"). The “historybackup” and “historyfilename” parameters are used in conjunction with the parameter “keephistory” should it be desired to keep an additional history file of the backup file. In general, this capability is used only if higher levels of data recovery are warranted. The “log” parameter specifies what type of logging you want performed, value of “s” means summary (default), value of “f” means full and value of “n” means none. The two commands necessary are “My Documents\Backup Job\backup.bat full” and “My Documents\Backup Job\backup.bat incremental”. It is recommended that you automate these two tasks to execute at scheduled times using the Windows Scheduler (Start/All Programs/Accessories/System Tools/Scheduled Tasks). Operation is to perform a full backup initially and then again when daily accumulated incremental backup file size dictates it (recommended weekly). It is recommended that incremental backups are performed daily at noon or just after the end of the workday but avoid the 10PM to 6AM timeslot when university-wide system backups occur. It is also possible that an individual Windows shortcut for the daily backup be created so a user can run these programs on demand. We recommend the full backup be performed weekly on Wednesday early evening before 10PM and the incremental backups performed daily at noon or just after the individual's workday and before the weekly backup time. ***NOTE*** - As this routine utilizes the Windows Username and password signon capability, be forewarned that when a User's Windows password change is done then the automatically scheduled tasks must be manually supplied the new password or these jobs will fail and there is little notice. The failures will only be noted in the Schedule Tasks/Advanced/View Logs area as error codes cannot be picked up by the batch file errorlevel checks. We recommend users be trained to be able to view this log and to be able to initiate these backup jobs upon their desire. Tom --------------------------------------------------------------------------------------------- :start set backuppath=\\ITSBackup1.ad.uni.edu\Backups\%username% set whattobackup="@%userprofile%\My Documents\Backup Job\Backup.bks" set wheretobackup="%backuppath%\Backup.bkf" set historybackup="%backuppath%\BackupHistory.bkf" set historyfilename=BackupHistory.bkf set log=s if %1. == setup. goto :setup if %1. == full. goto :fullbackup if %1. == keephistory. goto :keephistory if %1. == incremental. goto :incrementalbackup echo *** *** Error *** - Backup Command Failed Due To Incorrect Format echo *** echo *** echo *** The correct formats to execute this routine are: echo *** echo *** backup full echo *** backup keephistory echo *** backup incremental echo *** goto end :setup echo *** echo *** echo *** echo *** Beginning Backup Setup Routine Directories echo *** echo *** echo *** echo on md %whattobackup% md %wheretobackup% goto end :incrementalbackup echo *** Performing Daily Incremental Backup echo *** echo *** echo *** This routine added new and/or modified files to your daily backups. echo *** echo *** This will have the affect of making your backup current to the minute. echo *** echo *** %test% ntbackup backup %whattobackup% /J "Daily - Incremental Append to Backups" /A /M incremental /F %wheretobackup% /L:%log% goto end :keephistory %test% del %historybackup% %test% ren %wheretobackup% %historyfilename% :fullbackup echo *** Performing Full Backup - Restarting Entire Backup File echo *** echo *** echo *** echo *** This routine has intentionally restarted your backup routine scheme and echo *** will overwrite your previous backup on your network drive. echo *** echo *** Note that previous backups remain available from the tape backup library echo *** for an additional 30 days. echo *** echo *** %test% ntbackup backup %whattobackup% /J "Restarting with a Full Backup" /M normal /F %wheretobackup% /L:%log% :end if errorlevel 1 goto :error goto successful :error echo *** echo *** echo *** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** ERRORS - Backup did NOT complete successfully - REPORT ERRORS IMMEDIATELY*** echo *** pause goto stop :successful echo *** echo *** echo *** echo *** Processing Completed Normally ! ! ! echo *** echo *** rem ***Note*** Never Place A Permanent Pause Here As A Backup Job May Not End Within Time rem Limits When Run As A Scheduled Task - Tom Peterson :stop