I recently had a lot of trouble with a 4TB drive that my wife was using to back up her media files due to some corruption. After my effort with chkdsk and ntfsfix yielded only partial results, I decided that a better solution would be to make use of a NAS and had access to couple of used ZyXEL NSA310. I figured that I will format a drive with EXT4 and pop that in this box for some stable CIFS samba file acess. It turned out that the NSA310 does not recognise EXT4 (what can be more stupid that that!). And so after initial hesitation, I flashed it with OpenWRT 19x using a serial to USB cable. Due to my error, I ended up bricking the first flash but it truns out that they devices are brick proof and I was able to boot off from with the serial cable and flashed it correctly.
The box is pretty simple and we were off to races when the next demand came and that was once every three months she would like this NAS to sync with the 4TB drive as a second backup. The NSA would be mostly kept off and switched on periodically to siphon off some stuff from laptop.
I tried scheduled jobs with @reboot but it turned out that as per https://dev.archive.openwrt.org/ticket/12438 the @reboot is an extension to the BSD crond, not supported by Busybox crond. So that left me with two other options:
- Use the copy button and program that to "rsync -aqr --no-W" from internal hdd to usb hdd
or
- Hook up USB, switch on and let the box "rsync -aqr --no-W" from internal hdd to usb hdd.... say a minute after it boots up
I opted for the second option.... for now and will try and investigate the first option at a future date.
The current version (19x) uses /etc/init.d/ directory to enable services and so I created a file it that directory with nano /etc/init.d/atreboot and following content:
#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org
START=99
STOP=99
start() {
rsync -aqr --no-W /mnt/int-hdd/ /mnt/usb-hdd/
# This is executed when this service is started either manually or upon boot
}
Then I chmod +x /etc/init.d/atreboot
then I enabled this service using /etc/init.d/atreboot enable
Voila, when I switched off and restarted the machine the desired result was observed.
I hope this recipe is useful and inspires more complex recipes.
Best