DataLocker drives can be part of a comprehensive backup strategy and are an ideal solution for local backup. In this article we will look at an example using the Microsoft tool robocopy to copy a folder onto a secure USB storage device as part of a daily scheduled backup.


Backup script

This batch script will create a mirrored copy of the source folder in the destination folder that you configured. The script will find the drive no matter which letter it is mounted at. You can also configure many additional parameters with Microsoft robocopy as per the documentation. Furthermore, robocopy can of course be replaced with the backup tool of your choice.

Copy the code below into an empty file and save it as, for example, backup.bat

Lines that have # in front must be configured or controlled and then remove the #, the example script is provided as is, without warranty and specific support under an MIT-0 license. Click the bat-file to run the script and ensure that it is correct.


@echo off
setlocal

REM Display a message indicating it's time to take a backup
echo Time to take a backup!

:START
REM Set the source directory to be backed up, replace sample source_dir
#   set "source_dir=C:\Users\"

REM Set the destination directory on the secure USB drive, change sample dest_dir if needed
#  set "dest_dir=backup"

REM Configure the disk label of the secure USB drive for the script to find, change sample usb_label name DataLocker as needed
#  set "usb_label=DataLocker"

REM Find the drive letter of the secure USB drive
for /f "tokens=2 delims==" %%I in ('wmic volume where "Label='%usb_label%'" get driveletter /format:list ^| find "="') do (
    set "usb_drive=%%I"
)

REM Check if the secure USB drive is mounted
if not defined usb_drive (
    echo The DataLocker drive could not be found. Please unlock the drive and try again.
    pause
    goto :START
)

REM Check if the backup destination directory exists, create if not
if not exist "%usb_drive%\%dest_dir%\" (
    mkdir "%usb_drive%\%dest_dir%"
)

REM Set the timestamp for the backup with a valid filename format
for /f "tokens=1-4 delims=/ " %%a in ("%date% %time%") do set "timestamp=%%a-%%b-%%c_%%d"
set "timestamp=%timestamp::=-%"
set "timestamp=%timestamp:,=-%"
set "timestamp=%timestamp:.=-%"

REM Perform the backup using robocopy (mirror backup)
#  robocopy "%source_dir%" "%usb_drive%\%dest_dir%" /FFT /Z /R:3 /log+:"%usb_drive%\%dest_dir%\Backup_Log_%timestamp%.txt"

REM Notify user that backup is complete
echo Backup completed successfully. Great work!
pause

goto :START

endlocal


A copy of the script is located below as an attachment

Schedule Backup Script

To schedule the batch script to run automatically on a schedule in Windows, you can use the built-in Task Scheduler tool. Here's how you can do it:

  1. Open Task Scheduler

    • Press Win + R to open the Run dialog, then type taskschd.msc and press Enter.

  2. Create a New Task

    • In Task Scheduler, click on "Create Basic Task" or "Create Task" in the right-hand panel (either will work).

    • Enter a name and description for the task to identify it easily.

  3. Set Trigger

    • Choose how often you want the task to run. For daily backups, select "Daily."

    • Set the time you want the task to start running each day.

    • You can set other triggers if needed, such as at log on or when the computer starts.

  4. Set Action

    • Select "Start a Program" as the action.

    • Browse and select the batch script you created.

  5. Configure Additional Settings

    • Under the "Settings" tab, you can specify additional settings, such as whether the task should run only when the user is logged on, or whether it should run even if the user is not logged on.

  6. Confirm and Finish

    • Review the summary of the task and click "Finish" to create the task.

  7. Enter Credentials (if needed)

    • If the task requires elevated privileges or needs to run under a different user account, you may be prompted to enter the appropriate credentials.

Once the task is created, it will run automatically according to the schedule you specified. You can also manually run the task from Task Scheduler to test it.

Make sure the script file and all necessary resources are accessible and correctly configured. You may need to adjust the settings or triggers based on your specific requirements.

*Please note that DataLocker DL4 drives are hardcoded to either be a "fixed" or a "removable" drive. Below is a list of SKU's for each*

Removable

DL4-500GB-FE

DL4-1TB-FE

DL4-2TB-FE

DL4-SSD-1TB-FE

DL4-SSD-2TB-FE


Fixed


DL4-SSD-4TB-FE

DL4-SSD-7.6TB-FE

DL4-SSD-15.3TB-FE