Clone a Clone

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 update
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.


Posted

in

, ,

by

Tags:

Comments

Leave a Reply