I like playing and changing images and softwares on my WDmycloud
So I found it usefull to keep a full backup of my latest working image
Here is what you need to do
ssh to your wdmycloud IP then
mkdir /shares/wdcurrent
cd /shares/wdcurrent
create a new file called backup.sh
nano /shares/wdcurrent/backup.sh
copy the following to the nano editor
kernel=0config=0rootfs=0now="$(date)"echo "Full Backup Started at" "$now"echo "Full Backup Started at" "$now" >> backup.log# ------ kernel section---------now="$(date)"echo "Taking Kernel Backup" "$now"dd if=/dev/sda5 conv=sync,noerror bs=64K of=/DataVolume/shares/wdcurrent/kernel.imgnow="$(date)"echo "Kernel Backup completed at" "$now"echo "Checking Kernel backup Integrity"if [-f /DataVolume/shares/wdcurrent/kernel.img]; then now="$(date)" filedate="$(date -r /DataVolume/shares/wdcurrent/kernel.img)" if ["$filedate" == "$now"];then echo "Kernel Backup completed successfully at" "$now" kernel=1 echo "Kernel Backup completed successfully at" "$now" >> backup.log else echo "New Kernel Backup but Failed old backup still exist" "$now" echo "New Kernel Backup but Failed old backup still exist at" "$now" >> backup.log fielseecho "Kernel Backup Failed - backup file does not exist" "$now"echo "Kernel Backup Failed - backup file does not exist at" "$now" >> backup.logfi#--------Config Section----------now="$(date)"echo "Taking Configurations Backup" "$now"dd if=/dev/sda7 conv=sync,noerror bs=64K of=/DataVolume/shares/wdcurrent/config.imgnow="$(date)"echo "Configurations Backup completed at" "$now"echo "Checking Configurations backup Integrity"if [-f /DataVolume/shares/wdcurrent/config.img]; then now="$(date)" filedate="$(date -r /DataVolume/shares/wdcurrent/config.img)" if ["$filedate" == "$now"];then echo "Configurations Backup completed successfully at" "$now" config=1 echo "Configurations Backup completed successfully at" "$now" >> backup.log else echo "New Configurations Backup but Failed old backup still exist" "$now" echo "New Configurations Backup but Failed old backup still exist at" "$now" >> backup.log fielseecho "Configurations Backup Failed - backup file does not exist" "$now"echo "Configurations Backup Failed - backup file does not exist at" "$now" >> backup.logfi#----------rootfs section --------now="$(date)"echo "Taking Filesystem Backup" "$now"dd if=/dev/md0 conv=sync,noerror bs=64K of=/DataVolume/shares/wdcurrent/rootfs.imgnow="$(date)"echo "Filesystem Backup completed at" "$now"echo "Checking Filesystem backup Integrity"if [-f /DataVolume/shares/wdcurrent/rootfs.img]; then now="$(date)" filedate="$(date -r /DataVolume/shares/wdcurrent/rootfs.img)" if ["$filedate" == "$now"];then echo "Filesystem Backup completed successfully at" "$now" rootfs=1 echo "Filesystem Backup completed successfully at" "$now" >> backup.log else echo "New Filesystem Backup but Failed old backup still exist" "$now" echo "New Filesystem Backup but Failed old backup still exist at" "$now" >> backup.log fielseecho "Filesystem Backup Failed - backup file does not exist" "$now"echo "Filesytem Backup Failed - backup file does not exist at" "$now" >> backup.logfi#------Final report ----if ["$kernel" == "1"] && ["$config" == "1"] && ["$rootfs" == "1"] ; thenecho "Backup Fully Successful at" "$now"elseecho "Backup Failed at" "$now" "Please review backup.log for more details"fi
click Ctrl+x then y to save your file
make th patch executable
chmod +x /shares/wdcurrent/backup.sh
make a test backup to make sure that your script is functioning correctly
./shares/wdcurrent/backup.sh
schedule the batch to run automaticaly
I have scheduled it to run every 2 days at 7 AM ( feel free to change the schedule based on your need )
crontab -e
copy the below line to the crontab file
0 7 * * 0,2,4,6 /shares/wdcurrent/backup.sh
click Ctrl+x then y to save your file
you can check the status of your backups and the backup execution by viewing the backup.log at /shares/wdcurrent/backup.log
nano /shares/wdcurrent/backup.log