I was looking for a simple but effective solution to use external USB disk drives attached to my server for backup with backup applications that do not directly support USB drive rotation / swapping.
Unfortunately, Windows does not seem to support assigning the same drive letter to different USB drives, e.g. you cannot assign the letter U: to two different USB drives. This would be nice to be able to rotate the drives but it does not work. So my idea was to use a network share name that automatically mounts different USB drives to the same share name, depending on which USB drives are connected, that creates some sort of priority as we will see. An additional advantage is that drive can be also accessed directly from other computers through the network share.
The first step is to assign different drive letters to each USB disk through Windows disk management, e.g. U: and V:. Then create the same directory to be shared on each drive, e.g. "USB_SHARE". Backups will be stored there.
Then a simple batch file (usb_share.bat) can be created. First the share name USB_SHARE is auto-deleted (if it should already exist). Then we attempt to connect that share name to the USB drives. This will of course only succeed if the corresponding drive is attached to the PC. I.e. if U: is attached, it will be mounted as the share, if it is not attached, V: will be attempted to be mounted as the share. With "grant" we can give the appropriate network permissions, make sure that NTFS permissions also apply. So we can enter the following in the batch file:
net share USB_SHARE /delete
net share USB_SHARE=U:\USB_SHARE /grant:Everyone,FULL
net share USB_SHARE=V:\USB_SHARE /grant:Everyone,FULL
This batch file can be executed manually after connecting a USB drive and it can also be setup to be run automatically on computer startup, e.g. through the task scheduler on a Windows Server OS (make sure you tell Windows to execute it with admin permissions).
Hope this helps!