So I had yet another WD MyBook die on me a couple of days ago. Â And I still went out and bought another one (what was Einstein’sÂ definition of insanity, again?)… This one was only two years old but these things are still quite cheap and very convenient to get. Â Maybe someday when I have more money I will get a proper NAS enclosure. Â For now, my pattern is to buy a new one every year. Â They’ve almost doubled in size every time, so I can just clone everything to the new one and go from there.
Since I had suchÂ great experience with my WD MyBook Live, I decided to get the next version, a MyCloud. Â This is slightly improved, similar in appearance, also with a GB network port but this one also has a USB 3.0 host on it, so I can buy another, regular drive next and slave it off of this one.
My previous scheme didn’t seem to work well with this one, though. Â I was unable to make an unattended rsync to push from that drive to this one because these drives are set up to use root as the ssh user, andÂ it’s not set up to use PermitRootLogin without-password . Â It always seems to prompt for the password, which won’t work when AFK.
Until I figure that one out, I looked for another solution. Â The coolest discovery was that these drives are actually running Debian. Â After some research I found out that lftp will mirror a remote directory over FTP. Â Of course, lftp is not installed on these drives, however, after running…
apt-get install lftp
I had them installed (on both the 2012 and 2015 vintage drives).
Next was the task of setting them up! Â I found a good post on StackExchange (well, ServerFault) here that helped a lot. Â I ended up using this:
#!/bin/sh #TESTMODE="--dry-run" HOST="xxx.xxx.xxx.xxx" USER="username" PASS="secretpasswordseriouslyguys" FTPURL="ftp://$USER:$PASS@$HOST" LCD="/shares/Jonathan" RCD="/jonathan" #DELETE="--delete" #VERBOSE="--verbose" EXCLUDE="--exclude-glob .Trash*/ \ --exclude-glob .TemporaryItems/ \ --exclude-glob .AppleDouble \" lftp -c "set ftp:list-options -a; open '$FTPURL'; lcd $LCD; cd $RCD; mirror --no-umask --only-newer --use-cache --parallel=3 \ $TESTMODE \ $DELETE \ $VERBOSE \ $EXCLUDE "
With that I had some options I could use by uncommenting DELETE or TESTMODE, for example. Â One additional gotcha is that it doesn’t retain the source’s ownership, but since this is such a basic setup, I just chown all the files in the LCD variable to my username.
The password for that user is in cleartext, in the file. Â If you are not comfortable with that, do not use this.
It still doesn’t seem to be running in cron yet, but I need time to experiment some more. Â I still much prefer the SSH method but I want to get it working reliably and repeatably. Â I need to reimplement much of this each timeÂ the firmware gets updated, and copying a few files is much better than having to edit sshd config files each time.