I discovered the other day that my WD MyBook Live is a lot more capable than I realized. It is actually running some flavour of Debian and has a fair suite of default unix commands.
So what did I do with it? I didn’t go too wild… Due to the death of a previous MyBook (capacitor problems on the interface board, I think), I decided I wanted some mirroring capability on it with another drive attached to my server Linux machine. Fortunately, on the Live, I found rsync, ssh and cron, which seems like the power trio I needed.
First step, enable SSH. That was too easy, go to http://address/UI/ssh and check a box. Done! The instructions for logging in are there.
Next, log in by ssh and create a ssh key pair… Something like
ssh-keygen -t rsa
Use no password on this one, and store the keys in /root/.ssh – it seemed reasonable enough (do I need to tell you that you need to guard this key carefully, as it leaves the door wide open to your server?). Next, copy the public key over to the other machine…
scp /root/.ssh/id_rsa.pub [email protected]:/home/username
And on the server
cat id_rsa.pub >> .ssh/authorized_keys
Test it out on the MyBook again…
ssh -i ~/.ssh/id_rsa [email protected]
Next, test out rsyncing. I found out that the directories created through the GUI and through file sharing are on /DataVolume/shares, so…
rsync -e ssh -avz --dry-run --delete /DataVolume/shares/storage/ [email protected]:/path/on/the/server/storage/
It should pull in the key and do a dry run of the sync. If it works, try without the –dry-run switch and run the real sync. This will take some time depending on the amount to sync.
The switches are -e to execute ssh, -a to sync recursively and preserve permissions and symlinks, -v to be verbose, and -z to use compression. You can remove the -v portion before putting it in cron.
Speaking of which put the above successful command line into a shell script and copy it into /etc/cron.daily. Don’t forget to make it executable.
Very cool! The Live series of drives is now called the MyCloud, and is more powerful yet, including a stronger CPU and a USB host. It’s probably worth having at least one of these devices on a local network for part of a comprehensive backup strategy.