I posted an alternative to Safepoint under a previous posting commencing “Happy accident…”. The move to the new forum style corrupted the formatting. Here, for anyone who wants it is my original post, correctly formatted. It’s worked well for me for five months now, including a disaster recovery that went smoothly, I appreciate that some of the scripts could possibly be more elegant to those more experienced than myself, but this does have one advantage - it works!
This will back up any shares that you want, and is far more reliable, to my mind at least than Safepoint
Using WinSCP (easiest) or PuTTY create a folder called “Backup” on your USB drive, inside that folder create a separate folder for each of your shares. It may also be worth renaming the share name of your USB drive to something simple such as “USBbackup” which is the name I’ll use here.
To prevent your scripts being overwritten by future firmware updates, create a share called ‘system’ (for example) and place a folder in there called, say 'Tasks". I shall use these and the above names in what’s to follow.
With acknowledgements to Arty2, we’ll create the Python email script. Go into PuTTY then:
nano /shares /system/Tasks/mail.py
Paste (right click) the following into the editor
-- coding: utf-8 --
from email.header import Header
from email.mime.text import MIMEText
from getpass import getpass
from smtplib import SMTP_SSL
# edit the areas between the quotes in the line line below with your own settings
login, password, server, recipients = “the e.mail.account.you’email@example.com”, “password”, “smtp.gmail.com”, "firstname.lastname@example.org"
subject = sys.argv
body = sys.argv
msg = MIMEText(body, ‘plain’, ‘utf-8’)
msg[‘Subject’] = Header(subject, ‘utf-8’)
msg[‘From’] = login
msg[‘To’] = recipients
s = SMTP_SSL(server, 465, timeout=10)
s.sendmail(msg[‘From’], recipients, msg.as_string())
except Exception, error:
print “Unable to send e-mail: ‘%s’.” % str(error)
Come out of the editor. Now we’ll create the backup script
add your share names where share1 etc appear below
rsync -a /shares/share1/ /var/media/USBbackup/Backup/share1/
rsync -a /shares/share2/ /var/media/USBbackup/Backup/share2/
Continue adding as many shares as you like using the above syntax.
Finally, the email to confirm the backup completed:
python /shares/system/Tasks/mail.py “Message from WD MyCloud” “System backup has been completed successfully”
Having come out of the editor, make the script executable:
chmod +x /shares/system/Tasks/backup.sh
Now add a task with crontab, the following will run the backup at 0100 each day
add the line
00 01 * * * /shares/system/Tasks/backup.sh
Your backup will run at the required time and will send you an email when the task is completed.
That’s it for the backup.
For restoring, have a script ready, once again using nano, as my shares are quite large I wanted to keep an eye on progress so asked it to send me an email after each share had been restored:
rsync -a /var/media/USBbackup/share1/ /shares/share1/
python /shares/system/Tasks/mail.py “Message from WD MyCloud” “Share1 restore has been completed successfully”
rsync -a /var/media/USBbackup/share2/ /shares/share2/
python /shares/system/Tasks/mail.py “Message from WD MyCloud” “Share2 restore has been completed successfully”
add further shares as you wish, exit and save
make this script executable
chmod +x /shares/system/Tasks/restore.sh
now a final script, this will enable you to send an instruction to the MC to execute the restore script unattended
nohup /shares/system/Tasks/restore.sh > /dev/null 2>&1 &
exit and make this script executable
chmod +x /shares/system/Tasks/startrestore.sh
To recover after a wipe of your MC, once you’ve manually set up your shares again, configured the MC and given yourself SSH access (not forgetting changing the root password), use WinSCP to manually copy the backup of your ‘system’ share to the MC (should only take a min), then open PuTTY.
Give it the command:
The restore will start running, PuTTY will return almost immediately to the command prompt, the restore will run in the background without any further intervention, and you’ll get emails to tell you how it’s going.
Of course if you just want to restore the odd file or folder that you’ve accidentally lost you can use WinSCP to copy the files/folders across from the USB drive.
Hope this is of help. There may be typos or unintended line-breaks in the above for which I apologise.