I just wanted to thank you for this post, and give an update for anyone looking to follow this.
I am running a gen2 at firmware 2.31.183.
The main difference was that the nano command to edit files did not exist, so vi was used instead. Also, the USB share was not under /var/media, but was in the /shares directory itself. I also added the --delete argument to keep the copies matching.
As mentioned, the formatting of the e-mail script is not correct, and you should just reference arty2’s post to get the correct formatting as previously mentioned. Even the indentions in the try/except block matter. Arty2’s script did not need further modification for me, other than entering my personal account information.
I use gmail with two factor authentication, which required an app specific password to be generated for the script. This is done through gmail account settings.
I later learned that the WD Cloud has jobs that rebuild the list of scheduled cron jobs, and to allow your entry to remain, you need to edit a config.xml file. I followed andrewismoody’s instructions at the bottom of this thread, then restarted the cloud device. It sounds like incorrect formatting when editing the config.xml could prevent access to your device and require a 40s reset, but that should not cause loss of data. So, be careful when doing this. I copied existing XML elements and pasted, then edited those to ensure proper formatting. Crontab on MyCloud EX2
Finally, I ran the backup script for the initial copy, which took over a day for me, and I was concerned about a backup running over 24 hours and having two rsync jobs running at the same time. I updated my backup script with an or command, which would avoid the backup if any rsync jobs were running. This device didn’t have pgrep, and I haven’t studied unix in over a decade, so there is surely a better method. However, this is what I did to prevent the backup from running if an rsync job is already running.
ps -ef|grep rsync|grep -v grep || rsync -a --delete /shares/Public/ /shares/My_Book_1230-2/Backup/Public/
ps -ef|grep rsync|grep -v grep || python /shares/System/Tasks/mail.py “Message from WD MyCloud” “System backup of share Public has been completed successfully”
And one final note not really related to this thread, I had a lot of trouble getting the external USB device to mount. It was a 4TB WD My Book I previously used for an Xbox One, and was formatted for Xbox games. I initially plugged in the device before reformatting, and I think the My Cloud remembered the Xbox formatting instead of picking up the new NTFS formatting. I tried everything, deleting partitions, formatting as MBR and GPT, etc… the drive wasn’t identified until I formatted it as HFS+, and as you can see the cloud added the share with an -2 at the end, which I believe indicates a duplicate. Anyway, someone smarter than me could explain this, but I suspect the cloud wasn’t picking up on the NTFS reformat, and thought it was still formatted for Xbox, but the HFS+ format was different enough for it to be seen as new. Just a theory.