Home Backups System - Adding HDD Automatic Power Control

Some time ago I decided to make an automatic backups system for the data in my household PCs. The implemented solution was presented in the article Home Backups System. While solving my issue regarding the lack of a consistent system for data backups, the solution still required some improvements.

After the first overnight run of the backups system, I noticed the USB disks drives (from now onward USB HDDs) kept powered on and spinning from time to time despite not being used. It just happens that as long as the USB host (the Raspberry Pi board) was connected the USB drives kept powered up and did not go into a kind of sleep mode, as I expected.

This situation for me was an issue. These two HDDs are used only for the automatic daily backups of my home PCs, which is a process that only runs at evening and at dawn. For the remaining time the HDDs being powered up is inefficiency plain and simple.

Being an engineer this idea of unnecessary heat, mechanical wear and power consumption just annoyed me. A solution had to be found.

After some research I opted by a solution based on the YKUSH Hub from Yepkit. This YKUSH USB hub has the functionality of allowing the user to control the powering ON/OFF of the devices connected to it through commands in the host command line.

In the new setup the USB HDDs are connected to the Raspberry Pi through the YKUSH hub. I connected the HDD 1 to YKUSH downstream port 1 and the HDD 2 to YKUSH downstream port 2. The YKUSH upstream port is connected to an USB port of Raspberry Pi.

Now for the "soft" part, I started by getting the YKUSH Linux command from the product page and followed the setup instructions. Once this was done I could power on and off the HDD 1 and 2 individually just with a command run in the Linux shell terminal. For example, to power off the HDD 1 I run the following command:

$ykush -d 1

To power it back on I run:

$ykush -u 1

Next the scripts being used in the backups system had to be modified to take advantage of the added YKUSH functionality. For ease of use I created new additional scripts to run in the Raspberry Pi which handle the HDDs connect/disconnect and mount/unmount in the file-system. These additional scripts are named:

  • hdd1Up.sh 
  • hdd2Up.sh
  • hdd1Down.sh
  • hdd2Down.sh


These scripts are available for download from my github repository homeBackupsSystem.

The hdd1Up.sh script performs the power-on of HDD 1 and subsequent mount in the file-system using the /mnt/hdd1 folder as root for HDD 1. The hdd2Up.sh script does the same but for the HDD 2 and mounting it in /mnt/hdd2 folder. The hdd1Down.sh and hdd2Down.sh scripts start by un-mounting the HDDs from the file-system and then turns off the HDDs.

Finally the backup scripts are modified so that hddxUp scripts run before the rsync command and hddxDown scripts run after rsync has finished.

Problem solved!

Comentários