1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | @echo off rem :----------------------------------------------------------------------------- rem : BACKUP SCRIPT rem : This script was prepared for backing up a Windows XP computer rem : to an external hard drive. rem : It will create a new folder named for the current date in the \backups folder of rem : the external drive, then copy the contents of the data folder on the computer. rem : If the external drive ever fills up - unlikely - simply delete the oldest rem : folders from the backup folder to free up room. rem : The script assumes that the external drive is drive letter K: and the rem : data folder on the source computer is "C:\Documents and Settings". rem :----------------------------------------------------------------------------- rem Set configuration - change these values if necessary set backup_drive=K: set source_folder=C:\Documents and Settings title Data Backup rem Remind the user to close all applications - open files may interfere echo. echo Preparing to backup computer data to external hard drive. echo. echo - This backup may take several hours. It may best be done overnight. echo - All applications, including email, should be closed first. echo. echo Are you ready to proceed? :loop set Choice= set /P Choice=Type [Y]es or [N]o and press Enter: :: The syntax in the next line extracts the substring :: starting at 0 (the beginning) and 1 character long if not '%Choice%'=='' set Choice=%Choice:~0,1% echo. :: /I makes the IF comparison case-insensitive if /I '%Choice%'=='y' goto proceed if /I '%Choice%'=='n' goto skip echo "%Choice%" is not valid. Please try again. goto loop :proceed echo. echo Proceeding with backup... rem Change to backup drive and folder cd /d %backup_drive%\backups rem Create a folder for the current date and change to that directory md %date:~-4,4%-%date:~-10,2%-%date:~-7,2% cd %date:~-4,4%-%date:~-10,2%-%date:~-7,2% rem Start the file copy echo start > start.txt start /wait xcopy "%source_folder%" /E /C /H /R /Y echo finish > finish.txt rem Advise user that backup is completed. echo. echo Backup is completed. echo Files are stored at %backup_drive%\backup\%date:~-4,4%-%date:~-10,2%-%date:~-7,2%\ echo. color 2f goto end :skip echo. echo All programs should be closed before this starts. echo Please close all programs and try again. goto end :end echo. pause |
Categories