Post by drcard on Feb 8, 2021 20:24:59 GMT -5
Use Windows to Backup – Part 2
Overview:
This part explains how to set up automatic incremental backups of your personal data files and folders. The following instructions will show how to use the Robocopy utility in a bat file to perform a backup of your personal data files and Task Scheduler to make the process automatic.
Personal Data Backup
General
• You must know the exact location (PATH) of where the personal data is stored on your drive(s) and the exact location of where you want the backup copies to be stored.
• The files can not be open or in use when the backup is being performed.
• You must have administrator’s privileges to use Robocopy.
• The Robocopy options used will establish only one backup copy of your personal data files that are updated as needed with each backup.
• Consolidating as much of your personal data as you can into one folder or drive will make the backup process easier with fewer commands.
Create the Backup BAT File
• Open Notepad to a new document.
• The following lines of commands are entered into Notepad with no blank lines above the first command line and no spaces to the left of each command line. Below these lines of commands is an explanation of each command and those sections of the command that you must modify for your specific locations of Source and Storage.
%echo_off
robocopy_”SOURCE”_”STORAGE”_/B_/E_/IM_/R:5_/W:5_/MT:32_/LOG:”STORAGE\BkupLog.txt”
exit
• Replace each underscore (_) with a space. The underscores show where a space must be in the command.
• The %echo off command turns the display off so you don’t have to watch the command process.
• Replace SOURCE in the robocopy command with the exact PATH address to the drive or folder where your personal data is stored. Be sure to keep that PATH in the quote marks as in the example command above. Note: This is why it is easier to backup when you have all your personal data in one folder or drive to direct Robocopy to. You can create separate BAT files for each different folder location and run several scheduled backups, but your backups will not be stored together and increases the down time for the PC to run the backups.
• Replace STORAGE in the robocopy command with the exact PATH address to the drive/folder that the backups will be stored. Be sure to keep the PATH address in the quote marks. Use that same storage folder as part of the address with BkupLog.txt added to that folder. When placing the backups on an external drive, create a folder on the drive to store these backups in. This allows for different folders for different backups to be stored on that same drive and keep the backups separate.
• The /B option is the Backup option. This gives robocopy the security authority to access all files and folders on all drives. This is why robocopy has to be ran with Administrator’s privileges, which requires the logged on user to have Administrative rights to give those rights to robocopy.
• The /E option tells robocopy to copy all subfolders and files. This option is to make sure all folders and files within folders are copied.
• The /IM option tells robocopy to overwrite modified files. This option has robocopy compare a source file with the storage copy and replace the copy only if the source file has been modified. This option keeps only one backup copy. Also, after the first backup the backups will take much less time as only modified files are being copied.
• The /R:5 option tells robocopy to retry 5 times to access a file then stop and bypass that file. This option is needed because if a file was left open (which prevents robocopy access), robocopy by default will try 1,000,000 times to access a file which results in robocopy becoming hung.
• The /W:5 option tells robocopy to wait 5 seconds between retries. This option is needed because the default is 30 seconds, so an open file with 5 retries would take 3 minutes to bypass, but with this setting only 30 seconds.
• The /MT:32 option tells robocopy to increase its multi thread copying from the default of 8 to 32 which will make more copying in a shorter time frame.. Most PCs have hardware to handle 32 threads, but thread settings above 32 provide little speed advantage due to USB transfer rate limitations.
• The /LOG:”STORAGE\BkupLog.txt” option tells Robocopy to place the backup report named BkupLog.txt in that Storage folder. Be sure to replace STORAGE in the command with the PATH address to your Storage folder. If that txt file already exists (from a prior backup), robocopy will replace it with this new report. This will place the backup log in the same folder you selected to store the backups. Go to the storage folder and click this BkupLog.txt view a report of the last backup.
• The exit command is to exit the command function.
• After you have modified the command for your source and storage, select File>Save As… from the Notepad menu. Select a location to store the BAT file that is NOT in the drive or folder to be backed up. Click the dropdown arrow to the right of the Save as type: box and select All files (*.*). Name the file DataBkup.bat being sure to type in .bat as part of the file name. You can name the bat file anything you want, but will easier with a one word name.
• The result should be a BAT file named DataBkup.bat stored in a folder that is not part of the data that will be backed up.
• The next step is to test your BAT file as described in the next section.
Test the Backup BAT File
• Before testing your BAT file:
Make sure the PATHs in the BAT commands are correct and the folder the backups will be stored in has been created. Note: Anytime you want to view or edit the contents of a BAT file right click the file and select Edit from the context menu. Clicking the file to open it, runs the BAT file.
The external drive that will be used for storage is recognized by Windows and File Explorer.
That all the files and folders to be backed up are closed and not in use.
That you allotted computer down time to perform the backup. As a reference, most systems using the above command can copy from one external USB drive to another USB external drive at a 600 – 700 MB/minute or 40-45 GBs/hour rate. A copy from an internal drive to an external USB drive will be faster, especially if the external drive and port are USB 3.0.
• Once you completed the above steps and you are ready to run this backup, right click this DataBkup.bat file. Select Run as administrator. This will cause the UAC box to open for you to confirm the control you gave to run this BAT file. Click Yes. Th UAC box will close and it appears as nothing is happening.
• You may see the drive activity if the drive has a usage light and the command window may open. Give the PC time to backup all the data you had it back up. The first time may take a while, depending on how much data you have to back up. When you think the backup should be completed, look in the storage folder for BkupLog.txt. If present the first backup is completed, open the log and view the whole report. At the end of the report is the speed that the data was copied at. If the backup was not successful the report will state why. Most common error is the bat file was just clicked to run and was not Ran as administrator.
• Run the BAT file a second time and notice how quickly it finishes, and how short the new report is. This is because none of the files had changed since last backed up and no files needed copying.
• Now that you have a BAT file that will backup your personal data, the next section will instruct you how to make the backups automatic.
Automate Running the Backup BAT File
• We will use Task Scheduler to automate the running of this BAT file and thus the backups.
• Decide how often you want the backup to occur. Keep in mind that the files to be backed up cannot be open or in use at the time of the backup, after the first backup the backups will be modified files only (short backup time), and how often do you modify your personal data files. I modify my personal data daily and thus perform this backup every day at a time I am usually asleep. I will use those settings as an example below.
• Open Task Scheduler – Press Win key + R to open Run box. Enter taskschd.msc and press Enter key.
• Once the Task Scheduler window opens, select Action>Create Task… from the top menu, which will open the Create Task window to the General tab.
• On the General tab:
Enter a name for this task in the Name: box. I named mine PersonalBkup.
In the Description box, enter a short description of what the task will do.
Under Security options, check the box next to Run with highest privileges. Without Run with highest privileges checked all backups will fail.
Click Triggers tab to display that page.
• On the Triggers tab:
Click the New… button to open the New Trigger window
The New Trigger window will open with Begin the task: On a schedule already chosen, which is what we want for this task.
Under Settings, select the how often this task is to be ran. After you select Daily you will see a setting to choose how mays days between backups. The same applies for weekly and monthly. For my example I chose Daily and Recur every 1 day.
Change the Start date and time to when you want the backups to start. The time you select will be the time the backup will occur every day. I set mine to 2:00 am.
Under Advanced settings, check the box next to Stop task if it runs longer than and select from the dropdown list a time period just a little longer than it would take to perform the backup. This is a safety feature not to hang your system if a glitch occurs. Be sure to click the Enabled box so this safety feature is turned on.
Press OK button to close the New Trigger window.
You will see the new trigger listed in the Triggers box.
Click the Actions tab to display the next page.
• On the Actions tab:
Click the New… button to open the New Actions window.
The New Action window will open with Start a program in the Actions: box, which is just what we want.
Click the Browse… button next to the Program/script: box and locate the BAT file you created (In my example above that would be DataBkup.bat). Once you select the file the PATH to the file will display in the box. Remember: the BAT file must not be kept with the data that is going to be backed up.
Press the OK button to save and close the New Action window and display the action in the Actions box.
Click the Conditions tab to display the next page.
• On the Conditions tab:
Under Power, check the box next to Wake the computer to run this task. If you have the default settings which has Windows go to sleep after a certain time period of non-use, this setting is necessary to have the backups run in the middle of the night.
Click the Settings tab to go to the last page.
• On the Settings tab:
The default settings on this page are acceptable, but change the Stop the task if it runs longer than: time to match that you used in the Trigger you created earlier.
Make sure that Allow task to be run on demand is checked so you can test your scheduled task.
Press OK button to save your task.
• The Create Task window will close and your task will be listed in the top center pane of the Task Scheduler. You might have to scroll thru the tasks to find your task (listed by the name you gave it).
• When the task is selected in the top center pane, it will be highlighted and display the settings for that task in the lower center pane. Great way to check the settings you entered when you created the task.
• Now that you have created your scheduled task, let’s test it to make sure it works.
• Testing is just like the testing of the BAT file in that the files to be backed up up can’t be in use.
• To test the task: Highlight the task in the top center pane and click Run in the right lower section of the Task Scheduler window.
• If a problem occurs, recheck the settings used to create the task.
• If no problems occur, then your personal data files will be backed up on a daily basis without you have to do nothing but make sure all the files are close before going to bed.
The cost for this protection is a little time and a few $ for an external drive to store the backups. Really a big bang for the buck. Even if you decide not to make backup images of your Windows drive, protecting your personal memories is what really counts.
Overview:
This part explains how to set up automatic incremental backups of your personal data files and folders. The following instructions will show how to use the Robocopy utility in a bat file to perform a backup of your personal data files and Task Scheduler to make the process automatic.
Personal Data Backup
General
• You must know the exact location (PATH) of where the personal data is stored on your drive(s) and the exact location of where you want the backup copies to be stored.
• The files can not be open or in use when the backup is being performed.
• You must have administrator’s privileges to use Robocopy.
• The Robocopy options used will establish only one backup copy of your personal data files that are updated as needed with each backup.
• Consolidating as much of your personal data as you can into one folder or drive will make the backup process easier with fewer commands.
Create the Backup BAT File
• Open Notepad to a new document.
• The following lines of commands are entered into Notepad with no blank lines above the first command line and no spaces to the left of each command line. Below these lines of commands is an explanation of each command and those sections of the command that you must modify for your specific locations of Source and Storage.
%echo_off
robocopy_”SOURCE”_”STORAGE”_/B_/E_/IM_/R:5_/W:5_/MT:32_/LOG:”STORAGE\BkupLog.txt”
exit
• Replace each underscore (_) with a space. The underscores show where a space must be in the command.
• The %echo off command turns the display off so you don’t have to watch the command process.
• Replace SOURCE in the robocopy command with the exact PATH address to the drive or folder where your personal data is stored. Be sure to keep that PATH in the quote marks as in the example command above. Note: This is why it is easier to backup when you have all your personal data in one folder or drive to direct Robocopy to. You can create separate BAT files for each different folder location and run several scheduled backups, but your backups will not be stored together and increases the down time for the PC to run the backups.
• Replace STORAGE in the robocopy command with the exact PATH address to the drive/folder that the backups will be stored. Be sure to keep the PATH address in the quote marks. Use that same storage folder as part of the address with BkupLog.txt added to that folder. When placing the backups on an external drive, create a folder on the drive to store these backups in. This allows for different folders for different backups to be stored on that same drive and keep the backups separate.
• The /B option is the Backup option. This gives robocopy the security authority to access all files and folders on all drives. This is why robocopy has to be ran with Administrator’s privileges, which requires the logged on user to have Administrative rights to give those rights to robocopy.
• The /E option tells robocopy to copy all subfolders and files. This option is to make sure all folders and files within folders are copied.
• The /IM option tells robocopy to overwrite modified files. This option has robocopy compare a source file with the storage copy and replace the copy only if the source file has been modified. This option keeps only one backup copy. Also, after the first backup the backups will take much less time as only modified files are being copied.
• The /R:5 option tells robocopy to retry 5 times to access a file then stop and bypass that file. This option is needed because if a file was left open (which prevents robocopy access), robocopy by default will try 1,000,000 times to access a file which results in robocopy becoming hung.
• The /W:5 option tells robocopy to wait 5 seconds between retries. This option is needed because the default is 30 seconds, so an open file with 5 retries would take 3 minutes to bypass, but with this setting only 30 seconds.
• The /MT:32 option tells robocopy to increase its multi thread copying from the default of 8 to 32 which will make more copying in a shorter time frame.. Most PCs have hardware to handle 32 threads, but thread settings above 32 provide little speed advantage due to USB transfer rate limitations.
• The /LOG:”STORAGE\BkupLog.txt” option tells Robocopy to place the backup report named BkupLog.txt in that Storage folder. Be sure to replace STORAGE in the command with the PATH address to your Storage folder. If that txt file already exists (from a prior backup), robocopy will replace it with this new report. This will place the backup log in the same folder you selected to store the backups. Go to the storage folder and click this BkupLog.txt view a report of the last backup.
• The exit command is to exit the command function.
• After you have modified the command for your source and storage, select File>Save As… from the Notepad menu. Select a location to store the BAT file that is NOT in the drive or folder to be backed up. Click the dropdown arrow to the right of the Save as type: box and select All files (*.*). Name the file DataBkup.bat being sure to type in .bat as part of the file name. You can name the bat file anything you want, but will easier with a one word name.
• The result should be a BAT file named DataBkup.bat stored in a folder that is not part of the data that will be backed up.
• The next step is to test your BAT file as described in the next section.
Test the Backup BAT File
• Before testing your BAT file:
Make sure the PATHs in the BAT commands are correct and the folder the backups will be stored in has been created. Note: Anytime you want to view or edit the contents of a BAT file right click the file and select Edit from the context menu. Clicking the file to open it, runs the BAT file.
The external drive that will be used for storage is recognized by Windows and File Explorer.
That all the files and folders to be backed up are closed and not in use.
That you allotted computer down time to perform the backup. As a reference, most systems using the above command can copy from one external USB drive to another USB external drive at a 600 – 700 MB/minute or 40-45 GBs/hour rate. A copy from an internal drive to an external USB drive will be faster, especially if the external drive and port are USB 3.0.
• Once you completed the above steps and you are ready to run this backup, right click this DataBkup.bat file. Select Run as administrator. This will cause the UAC box to open for you to confirm the control you gave to run this BAT file. Click Yes. Th UAC box will close and it appears as nothing is happening.
• You may see the drive activity if the drive has a usage light and the command window may open. Give the PC time to backup all the data you had it back up. The first time may take a while, depending on how much data you have to back up. When you think the backup should be completed, look in the storage folder for BkupLog.txt. If present the first backup is completed, open the log and view the whole report. At the end of the report is the speed that the data was copied at. If the backup was not successful the report will state why. Most common error is the bat file was just clicked to run and was not Ran as administrator.
• Run the BAT file a second time and notice how quickly it finishes, and how short the new report is. This is because none of the files had changed since last backed up and no files needed copying.
• Now that you have a BAT file that will backup your personal data, the next section will instruct you how to make the backups automatic.
Automate Running the Backup BAT File
• We will use Task Scheduler to automate the running of this BAT file and thus the backups.
• Decide how often you want the backup to occur. Keep in mind that the files to be backed up cannot be open or in use at the time of the backup, after the first backup the backups will be modified files only (short backup time), and how often do you modify your personal data files. I modify my personal data daily and thus perform this backup every day at a time I am usually asleep. I will use those settings as an example below.
• Open Task Scheduler – Press Win key + R to open Run box. Enter taskschd.msc and press Enter key.
• Once the Task Scheduler window opens, select Action>Create Task… from the top menu, which will open the Create Task window to the General tab.
• On the General tab:
Enter a name for this task in the Name: box. I named mine PersonalBkup.
In the Description box, enter a short description of what the task will do.
Under Security options, check the box next to Run with highest privileges. Without Run with highest privileges checked all backups will fail.
Click Triggers tab to display that page.
• On the Triggers tab:
Click the New… button to open the New Trigger window
The New Trigger window will open with Begin the task: On a schedule already chosen, which is what we want for this task.
Under Settings, select the how often this task is to be ran. After you select Daily you will see a setting to choose how mays days between backups. The same applies for weekly and monthly. For my example I chose Daily and Recur every 1 day.
Change the Start date and time to when you want the backups to start. The time you select will be the time the backup will occur every day. I set mine to 2:00 am.
Under Advanced settings, check the box next to Stop task if it runs longer than and select from the dropdown list a time period just a little longer than it would take to perform the backup. This is a safety feature not to hang your system if a glitch occurs. Be sure to click the Enabled box so this safety feature is turned on.
Press OK button to close the New Trigger window.
You will see the new trigger listed in the Triggers box.
Click the Actions tab to display the next page.
• On the Actions tab:
Click the New… button to open the New Actions window.
The New Action window will open with Start a program in the Actions: box, which is just what we want.
Click the Browse… button next to the Program/script: box and locate the BAT file you created (In my example above that would be DataBkup.bat). Once you select the file the PATH to the file will display in the box. Remember: the BAT file must not be kept with the data that is going to be backed up.
Press the OK button to save and close the New Action window and display the action in the Actions box.
Click the Conditions tab to display the next page.
• On the Conditions tab:
Under Power, check the box next to Wake the computer to run this task. If you have the default settings which has Windows go to sleep after a certain time period of non-use, this setting is necessary to have the backups run in the middle of the night.
Click the Settings tab to go to the last page.
• On the Settings tab:
The default settings on this page are acceptable, but change the Stop the task if it runs longer than: time to match that you used in the Trigger you created earlier.
Make sure that Allow task to be run on demand is checked so you can test your scheduled task.
Press OK button to save your task.
• The Create Task window will close and your task will be listed in the top center pane of the Task Scheduler. You might have to scroll thru the tasks to find your task (listed by the name you gave it).
• When the task is selected in the top center pane, it will be highlighted and display the settings for that task in the lower center pane. Great way to check the settings you entered when you created the task.
• Now that you have created your scheduled task, let’s test it to make sure it works.
• Testing is just like the testing of the BAT file in that the files to be backed up up can’t be in use.
• To test the task: Highlight the task in the top center pane and click Run in the right lower section of the Task Scheduler window.
• If a problem occurs, recheck the settings used to create the task.
• If no problems occur, then your personal data files will be backed up on a daily basis without you have to do nothing but make sure all the files are close before going to bed.
The cost for this protection is a little time and a few $ for an external drive to store the backups. Really a big bang for the buck. Even if you decide not to make backup images of your Windows drive, protecting your personal memories is what really counts.