From c55036611d4d358e575fa79599c6edf4ab3f5c5c Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 8 Oct 2017 15:12:01 -0400 Subject: [PATCH 1/8] added extra folders option -feature not yet complete --- Backup Script.bat | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Backup Script.bat b/Backup Script.bat index 451ab29..f3d0cfc 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -1,33 +1,47 @@ @echo off -echo Welcome to Staples Store #17 Tech Backup and Migrate script! +echo Welcome to Staples Store #17 Tech Backup & Migrate script! :mainmenu echo echo MAIN MENU echo 1. Backup Data echo 2. Migrate Data [COMING SOON] -set /P backMigSel=What would you like to do? +SET /P backMigSel=What would you like to do? IF "%backMigSel%"=="1" GOTO :backup echo Not a valid selection, please try again. GO TO :mainmenu :backup -set /P backDestLet=What is the drive letter of the drive to put the backup unto? -IF "%backDestLet%"=="c" GOTO :invalidletter -IF "%backDestLet%"=="C" GOTO :invalidletter +SET /P backDestLet=What is the drive letter of the drive to put the backup unto? +IF /I "%backDestLet%"=="c" GOTO :invalidletter IF NOT EXIST "backDestLet%:\" GOTO :invalid letter mkdir "%backDestLet%:\StaplesBackup" -mkdir %backDestLet%:\StaplesBackup\Users" +mkdir "%backDestLet%:\StaplesBackup\Users" robocopy "C:\Users" "%backDestLet%:\StaplesBackup\Users" /v /log:"%backDestLet%:\backupLog.txt" /e /zb /mt:4 /r:3 /w:3 /copy:dt /tee /eta /xj /xf "NETUSER.DAT" /xd "Local Settings" /xd "AppData" /xd "Application Data" /xd "C:\Users\All Users" /xd "C:\Default User" /xd "C:\Users\Default" /xd "C:\Users\DefaultAppPool" /xd "C:\Users\Default.migrated" echo "BACKUP COMPLETE. Displaying log file. start "" "E:\backupLog.txt" GOTO :end +:backupextrafolders +SET extracount=0 +:backupextrainput +SET /P backupExtraInput=Would you like to backup folders not present under Users[y/n]? +IF "%backupExtraInput%"=="y" GOTO :extrabackuploop +IF "%backupExtraInput%"=="n" GOTO :end +echo Invalid selection, please type y or n. +GOTO :backupextrainput + +:extrabackuploop +SET /A extracount=extracount+1 +mkdir "%backDestLet%:\StaplesBackup\Extra%extracount%" +SET /P backupExtraPath=What is the full path of the extra folder number %extracount%? + :invalidletter echo This is an invalid selection, try again. GOTO :mainmenu :end +echo TASKS COMPLETE. YOU HAVE REACHED THE END OF THE SCRIPT. pause From a3db920b550893ff38040202207b7f557d4b5805 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 8 Oct 2017 15:43:23 -0400 Subject: [PATCH 2/8] more extra folders stuff -also moved invalidletter higher and placed a skip statement above it --- Backup Script.bat | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Backup Script.bat b/Backup Script.bat index f3d0cfc..b12608b 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -17,6 +17,12 @@ SET /P backDestLet=What is the drive letter of the drive to put the backup unto? IF /I "%backDestLet%"=="c" GOTO :invalidletter IF NOT EXIST "backDestLet%:\" GOTO :invalid letter +GOTO skipinvalidletter +:invalidletter +echo This is an invalid selection, try again. +GOTO :mainmenu +:skipinvalidletter + mkdir "%backDestLet%:\StaplesBackup" mkdir "%backDestLet%:\StaplesBackup\Users" robocopy "C:\Users" "%backDestLet%:\StaplesBackup\Users" /v /log:"%backDestLet%:\backupLog.txt" /e /zb /mt:4 /r:3 /w:3 /copy:dt /tee /eta /xj /xf "NETUSER.DAT" /xd "Local Settings" /xd "AppData" /xd "Application Data" /xd "C:\Users\All Users" /xd "C:\Default User" /xd "C:\Users\Default" /xd "C:\Users\DefaultAppPool" /xd "C:\Users\Default.migrated" @@ -27,7 +33,7 @@ GOTO :end :backupextrafolders SET extracount=0 :backupextrainput -SET /P backupExtraInput=Would you like to backup folders not present under Users[y/n]? +SET /P backupExtraInput=Would you like to backup extra folders not present under Users[y/n]? IF "%backupExtraInput%"=="y" GOTO :extrabackuploop IF "%backupExtraInput%"=="n" GOTO :end echo Invalid selection, please type y or n. @@ -35,12 +41,20 @@ GOTO :backupextrainput :extrabackuploop SET /A extracount=extracount+1 +SET backupExtraPath[0]="EMPTY" mkdir "%backDestLet%:\StaplesBackup\Extra%extracount%" -SET /P backupExtraPath=What is the full path of the extra folder number %extracount%? +SET /P backupExtraPath[extracount]=What is the full path of the extra folder (include drive letter and backslashes, NOT frontslashes) number %extracount%? +SET /P backupExtraAgain=Add another folder to extra backups[y/n]? +IF "%backupExtraAgain%"=="y" GOTO :extrabackuploop +IF "%backupExtraAgain%"=="n" GOTO :performextrabackup +echo Invalid selection, please type y or n. +GOTO :backupextraloop + +:performextrabackup +SET performcount=0 +:performloop + -:invalidletter -echo This is an invalid selection, try again. -GOTO :mainmenu :end echo TASKS COMPLETE. YOU HAVE REACHED THE END OF THE SCRIPT. From 595fd5302737f12625718cb5404300ce8505aad6 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 8 Oct 2017 16:19:33 -0400 Subject: [PATCH 3/8] Complete extra folders -array was used here -should open the log file for each addition path added to backup -at the moment, extra backups are to be specified and performed after initial backup (which is Users folder) --- Backup Script.bat | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Backup Script.bat b/Backup Script.bat index b12608b..bcacdfd 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -26,8 +26,8 @@ GOTO :mainmenu mkdir "%backDestLet%:\StaplesBackup" mkdir "%backDestLet%:\StaplesBackup\Users" robocopy "C:\Users" "%backDestLet%:\StaplesBackup\Users" /v /log:"%backDestLet%:\backupLog.txt" /e /zb /mt:4 /r:3 /w:3 /copy:dt /tee /eta /xj /xf "NETUSER.DAT" /xd "Local Settings" /xd "AppData" /xd "Application Data" /xd "C:\Users\All Users" /xd "C:\Default User" /xd "C:\Users\Default" /xd "C:\Users\DefaultAppPool" /xd "C:\Users\Default.migrated" -echo "BACKUP COMPLETE. Displaying log file. -start "" "E:\backupLog.txt" +echo "INITIAL BACKUP COMPLETE. Displaying log file. +start "" "%backDestLet%:\backupLog.txt" GOTO :end :backupextrafolders @@ -53,8 +53,13 @@ GOTO :backupextraloop :performextrabackup SET performcount=0 :performloop +SET /A performcount=performcount+1 +echo Starting backup of extra folder number %performcount% +robocopy "backupExtraPath[performcount]" "%backDestLet%:\StaplesBackup\Extra%performcount%" /v /log:"%backDestLet%:\extraBackupLog%performcount%.txt" /e /zb /mt:4 /r:3 /w:3 /copy:dt /tee /eta /xj +start "Extra %performcount%" "%backDestLet%:\extraBackupLog%performcount%.txt" - +IF %performcount% LSS %extracount% GOTO :performloop +echo "EXTRA FOLDERS BACKUP COMPLETE. Displaying log file. :end echo TASKS COMPLETE. YOU HAVE REACHED THE END OF THE SCRIPT. From 06a81ca1697a370f203ff2ea27c138b851ec0abd Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 8 Oct 2017 16:43:31 -0400 Subject: [PATCH 4/8] Added lines to MAIN MENU --- Backup Script.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backup Script.bat b/Backup Script.bat index bcacdfd..66dec67 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -3,7 +3,7 @@ echo Welcome to Staples Store #17 Tech Backup & Migrate script! :mainmenu echo -echo MAIN MENU +echo ----------MAIN MENU---------- echo 1. Backup Data echo 2. Migrate Data [COMING SOON] SET /P backMigSel=What would you like to do? From b3ca422026f8100fc2a6ab114b6dd3319a7e6e87 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 8 Oct 2017 16:44:03 -0400 Subject: [PATCH 5/8] fixed intro line --- Backup Script.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backup Script.bat b/Backup Script.bat index 66dec67..ff75035 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -1,5 +1,5 @@ @echo off -echo Welcome to Staples Store #17 Tech Backup & Migrate script! +echo Welcome to Staples Store #17 Tech Backup and Migrate script! :mainmenu echo From e0c54fd3c5b73fedfb46a3a0326946ea67791441 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 15 Oct 2017 22:09:51 -0400 Subject: [PATCH 6/8] Fixed issue with :invalidletter there was a space in between invalid and letter which cause batch file to not find it --- Backup Script.bat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backup Script.bat b/Backup Script.bat index ff75035..5e204bb 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -15,12 +15,13 @@ GO TO :mainmenu :backup SET /P backDestLet=What is the drive letter of the drive to put the backup unto? IF /I "%backDestLet%"=="c" GOTO :invalidletter -IF NOT EXIST "backDestLet%:\" GOTO :invalid letter +IF NOT EXIST "backDestLet%:\" GOTO :invalidletter GOTO skipinvalidletter :invalidletter echo This is an invalid selection, try again. GOTO :mainmenu + :skipinvalidletter mkdir "%backDestLet%:\StaplesBackup" From 8687de108167c1310cdbe943e8631c02dae81270 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Sun, 15 Oct 2017 22:13:20 -0400 Subject: [PATCH 7/8] Fixed missing % that prevent drive letter check --- Backup Script.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Backup Script.bat b/Backup Script.bat index 5e204bb..333dd46 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -15,7 +15,7 @@ GO TO :mainmenu :backup SET /P backDestLet=What is the drive letter of the drive to put the backup unto? IF /I "%backDestLet%"=="c" GOTO :invalidletter -IF NOT EXIST "backDestLet%:\" GOTO :invalidletter +IF NOT EXIST "%backDestLet%:\" GOTO :invalidletter GOTO skipinvalidletter :invalidletter From 1ebd6989deae4ab7759cffdb68a45ff476725308 Mon Sep 17 00:00:00 2001 From: Alex Botelho Date: Mon, 16 Oct 2017 01:36:37 -0400 Subject: [PATCH 8/8] Added some remarks/comments --- Backup Script.bat | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Backup Script.bat b/Backup Script.bat index 333dd46..d2d1d04 100644 --- a/Backup Script.bat +++ b/Backup Script.bat @@ -6,21 +6,28 @@ echo echo ----------MAIN MENU---------- echo 1. Backup Data echo 2. Migrate Data [COMING SOON] -SET /P backMigSel=What would you like to do? +REM prompt between backup or migrate +SET /P backMigSel=What would you like to do? +REM if selection is 1, go to backup section IF "%backMigSel%"=="1" GOTO :backup +REM if not a 1, start again echo Not a valid selection, please try again. GO TO :mainmenu :backup SET /P backDestLet=What is the drive letter of the drive to put the backup unto? +REM C drive is automatically invalid for destination drive IF /I "%backDestLet%"=="c" GOTO :invalidletter +REM check if the selected drive is actually available IF NOT EXIST "%backDestLet%:\" GOTO :invalidletter +REM skips the next section to isolate it GOTO skipinvalidletter :invalidletter echo This is an invalid selection, try again. -GOTO :mainmenu +REM after inputting an invalid letter, we go back to backup section +GOTO :backup :skipinvalidletter