How to backup only to a specific removable/external drive

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

When you have multiple 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.

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

  1. Open Backup4all.
  2. Go to File->New backup.
  3. On the first page, enter a name for the backup in the Backup Name field.
  4. In the Where do you want to save the backup section, select external/removable drive as destination. Press Next.
  5. On the What do you want to backup page, add the backup sources. Press Next.
  6. On the third page, you can choose the backup type and the encryption. Press Next.
  7. Set when to run the backup.
  8. Press Save.

How to create the script

Steps to follow:

  1. 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

  1. Save it as test_drive.bat
  2. Connect the removable/external drive you want to use for backups.
  3. Open Windows command line and type: mountvol <drive>: /l  (<drive> is the drive letter of the removable drive used for backups)
  4. Copy the result of the above command. That is <drive_id>
  5. 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.

7. Select the “Abort backup if action fails”

8. Press Save.

  • Backup script

Comments


NEW: Backup4All 6.5.373