When you have multiple removable/external drives that you connect to your computer one at a time, they could be assigned with the same drive letter in Windows. When the scheduler runs, Backup4all will automatically run the backup to the currently connected hard drive assigned with the selected drive letter. If you want to use only one drive for backups and the others for different projects, you need to make sure the backup won't be executed on the wrong hard drive connected at that time.
Scenario description
In this article we will show you how to set Backup4all to verify which removable/external drive is connected at the backup time. If the correct drive is connected, the backup will run; otherwise the backup will abort.
You need to create script and run it before the backup. That will check the existence of the volumeID of the backup device and after that it will run (or abort) the backup.
How to create the backup job
- Open Backup4all.
- Go to File->New.
- On the DESTINATION - Where do you want to save your backup page, select external (or removable) option from the left side and select your drive from the right side, to be used as destination. Press Next.
- On the SOURCES - What do you want to backup page, select the backup sources. Press Next.
- On the FILTERS - Filter the backup sources page, you can set filters to include or exclude specific file/folders. Press Next.
- One the TYPE - How do you want to backup page, you can choose the backup type and you can set the encryption. Press Next.
- One the SCHEDULER - When do you want to backup page, you can select how frequent the backup to be executed. Press Next.
- One the JOB - Personalize your backup job page, you can enter a name for the backup in the Backup Name field.
- Press Save.
How to create the script
Steps to follow:
- Open Notepad and paste the following content:
>:: %1 - drive letter. ex c:
>:: %2 - known drive id. ex \\?\Volume{dd09e7c4-9545-11e3-8284-74d02b7dfc50}
>@echo off
>if "%2"=="" goto :error
>for /f "delims= " %%i in ('mountvol %1 /l') do set drive=%%i
>if not "%2"=="%drive%" exit /b 100
>exit /b 0
>
>:error
>echo Invalid syntax
>echo test_drive.bat <drive>: <drive_id>
>echo test_drive.bat C: \\?\Volume{dd09e7c4-9545-11e3-8284-74d02b7dfc50}
>exit /b 99
>
>:exit
- Save it as test_drive.bat
- Connect the removable/external drive you want to use for backups.
- Open Windows command line and type:
mountvol <drive>: /l
(drive is the drive letter of the removable drive used for backups) - Copy the result of the above command. That is
<drive_id>
- Open Backup4all and go to Backup Properties->Advanced. In the “Run action before backup” section, type:
“<path>test_drive.bat” <drive>: <drive_id>
Please make sure you replace<path>
(with the path where you saved the .bat file),drive>
(removable drive letter) and drive_id (result from step 3) variables with the correct ones. - Select the “Abort backup if action fails”
- Press Save.