What to do to mount/unmount drive before and after backup?

Hello,

I wrote this very, very, very simple cmd script to do some Kopia jobs, both local and offline. This is very simple example, how one can mount/unmount usb drivers for Kopia backup purposes.

echo off
cls

:main
echo --------------------
Echo Kopia Backup
echo --------------------               

set /p answer=1-Local Backup 1,  2-Local Backup 2, 3-USB Backup 1, 4-USB Backup 2,  X-Exit - 1/2/3/4 or X?
   
   if /i "%answer:~,1%" EQU "1" goto hdc
   if /i "%answer:~,1%" EQU "2" goto hdd
   if /i "%answer:~,1%" EQU "3" goto usb1
   if /i "%answer:~,1%" EQU "4" goto usb2   
   if /i "%answer:~,1%" EQU "X" goto exits
   
   echo Please type: 1/2/3/4 or  X -?
   
   goto main

:exits

exit /b


:hdc

rem - path to backup config

SET dest=repository-xxxxxx.config
SET name=Local Backup 1

rem also, passwords can be assigned to argument:
rem SET password=xxxxx

goto mainhd

:hdd

SET dest=repository-xxxxx.config
SET name=Local Backup 2

goto mainhd


:usb1

rem Path to usb backup.
rem Warring! As we connect it, Kopia always assign new default "respiratory.config" file, overwriting existing one. So, do not use default "respiratory.config" for local backups.

SET dest=g:\kopia\usb1
SET name=USB-1

goto mainusb

:usb2

SET dest= h:\kopia\usb2
SET name=USB-2

goto mainusb

:mainhd

echo ----------------
Echo Kopia - %name%
echo ----------------               

set /p answer=C-Backup. M-Mount. V-Verify. E-Exit - C/M/V or E?
   if /i "%answer:~,1%" EQU "C" goto backuphd
   if /i "%answer:~,1%" EQU "V" goto verifyhd   
   if /i "%answer:~,1%" EQU "M" goto mounthd
   if /i "%answer:~,1%" EQU "E" goto exitshd
   
   echo Please type C,M,V or E?
   
   goto mainhd

:mounthd

Echo "Mount..."

kopia --config-file=%dest% mount 

goto mainhd

:exitshd

goto main

:backuphd

Echo "Snapshotting..."

kopia --config-file=repository-%dest%  snapshot create --all  --password=xxxx

goto mainhd

:verifyhd

Echo "Verifying..."

kopia --config-file=%dest% snapshot verify --verify-files-percent=3
kopia --config-file=%dest% cache clear

goto mainhd

:mainusb

if exist %dest% ( 
echo "Connecting..."

kopia repository connect filesystem --path=%dest% --password=xxxxx 

echo "Connected!"

goto againusb

) else (

echo Please connect %name%-Drive!
Pause
goto main

)

:againusb

echo ----------------
Echo Kopia - %name%
echo ----------------        


set /p answer=C-Backup. M-Mount. V-Verify. E-Disconnect - C/M/V or E?
   if /i "%answer:~,1%" EQU "C" goto backupusb
   if /i "%answer:~,1%" EQU "V" goto verifyusb   
   if /i "%answer:~,1%" EQU "M" goto mountusb
   if /i "%answer:~,1%" EQU "E" goto exitsusb
   
   echo Please type C,M,V or E?
  
   goto againusb

:mountusb

Echo "Mount..."

kopia mount 

goto againusb

:exitsusb

Echo "Disconnecting..."

kopia repository disconnect

goto main

:backupusb

Echo "Snapshotting..."

kopia snapshot create --all 

goto againusb

:verifyusb

Echo "Verifying..."

kopia snapshot verify --verify-files-percent=0.1 

goto againusb