Standalone backup agent for Microsoft Windows servers and workstations (formerly Veeam Endpoint Backup FREE)
Post Reply
jeffshead
Enthusiast
Posts: 71
Liked: 3 times
Joined: May 05, 2016 1:07 pm
Full Name: Jeff
Contact:

Auto power-on/mount & unmount/power-off a USB drive

Post by jeffshead » 1 person likes this post

I know Veeam Agent for Windows includes the option to 'Eject removable storage once backup is completed' but this option is only available for Workstation and it leaves the drive physically connected to the server and powered on.
Image

Since ransomware is ever evolving, I’m sure there is or will be a variant that can remount an ejected USB drive. A quick Internet search will turn up a couple of ways of doing this without having to power-cycle or physically disconnect/reconnect the drive to the server. It’s also very likely that a person will forget to physically remove the drive and/or reconnect it to the server before the next scheduled backup.

I don’t know if this is overkill or not but I thought I’d share my way of automating the process. Since I’m a novice at best when it comes to scripting, I took the path of least resistance and went with a B&R managed agent backup job rather than attempting to script everything which would be a requirement for a stand-alone, agent managed backup job. With the B&R managed job, you will have the option to specify pre-job and post-job scripts; not to be confused with pre-freeze and post-freeze scripts. This made it a much less daunting task for me since I would not have to figure out how to determine, with scripting, when the backup job finished.
Image
To use the script, you would replace C:\scripts\pre-job.bat with C:\<your path>\usb_drv\drv_status.bat mount and replace C:\scripts\post-job.bat with C:\<your path>\usb_drv\drv_status.bat remove


Requirements:
  • Veeam B&R
  • USB drive enclosure or dock with external power
    • I use the Avastor HDX Pro enclosure but there are many brands to choose from.
    • This OWC is a great dock but it will NOT work because it requires you to physically power on/off each HDD, individually.
  • Remote power switch
    • The script can be tweaked for any make/model but it is written for Synaccess models.
    • These PDUs will also work; just have to tweak the script.
  • USB Safely Remove
    • The script can be tweaked to use Window’s mountvol, devcon.exe or whatever but I chose to use USB Safely Remove because it also spins down the drive whereas nothing else I tried was capable of doing so.
Basic process:
  1. INITIAL STATE - The USB drive is always physically attached to the backup server via USB cable but remains powered off.
  2. The B&R scheduled backup job runs the pre-job script which verifies if the volume is already mounted. If not, it sends a command to the Synaccess to power on the outlet. The backup repository is now available.
  3. The backup job performs the backup and then runs the post-job script which ejects and spins down the USB drive and finally switches the power outlet off.

Download the scripts (663KB):

Code: Select all

https://mir.cr/GZIIEIAJ
Password: Veeam

Please feel free to chime in and tell me if this is a waste of time or how you've improved the process or scripts ;-)
HannesK
Product Manager
Posts: 14322
Liked: 2890 times
Joined: Sep 01, 2014 11:46 am
Full Name: Hannes Kasparick
Location: Austria
Contact:

Re: Auto power-on/mount & unmount/power-off a USB drive

Post by HannesK »

Hello,
thanks for sharing your approach with the community.

Yes, using remote power switches* + scripts is something customers do from time to time. For small environments, your way is probably one of the best things possible with the budget size available. For larger installations, a Linux server with Veeam Hardened Repository is the preferred way (https://helpcenter.veeam.com/docs/backu ... ml?ver=110)

*replace "power switches" by whatever component can be configured remotely. I have seen switchport on / off, firewall rules on / off, user accounts on / off.

Best regards,
Hannes
Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests