How to backup only to a specific removable/external drive

This article applies only to Backup4all. If you don't have it yet, you must download it first.

Download Now
Buy Licenses
Jul 04, 2019

Backup4all 8.x

We strive to keep our articles as accurate as possible. If you notice any inconsistencies or outdated info please let us know.

How to backup only to a specific removable/external drive

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

  1. Open Backup4all.
  2. Go to File->New.
  3. 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.
  4. On the SOURCES - What do you want to backup page, select the backup sources. Press Next.
  5. On the FILTERS - Filter the backup sources page, you can set filters to include or exclude specific file/folders. Press Next.
  6. One the TYPE - How do you want to backup page, you can choose the backup type and you can set the encryption. Press Next.
  7. One the SCHEDULER - When do you want to backup page, you can select how frequent the backup to be executed. Press Next.
  8. One the JOB - Personalize your backup job page, you can enter a name for the backup in the Backup Name field.
  9. 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
  2. Save it as test_drive.bat
  3. Connect the removable/external drive you want to use for backups.
  4. Open Windows command line and type: mountvol <drive>: /l (drive is the drive letter of the removable drive used for backups)
  5. Copy the result of the above command. That is <drive_id>
  6. 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