I just cooked up a technique to auto backup routes, etc and restore them on reboot. I use this for my overlayroot filesystem, so I can have a read only file system and persistent routes and settings across reboot.
The technique is simple, create a partition to be used only to store
opencpn backup files. Add an entry to mount it in synchronous mode. For me my backup partition is mounted in /home/seth/bak, and
opencpn settings are in /home/seth/.opencpn.
Example from /etc/fstab:
Code:
UUID=93027524-0cc4-4a13-a339-5dd44363a029 /home/seth/bak ext4 rw,sync 0 1
create an empty directory to mount to:
Code:
mkdir /home/seth/bak
cause the new partition to be mounted
Now use this script, (mirror.sh in my example) and cause it to run at boot before opencpn is started:
Code:
#!/bin/bash
cp $2/* $1
while inotifywait -e modify,create,delete $1
do
rsync -lptgoDv $1/* $2
done
I made the script run at boot time (on mint) by adding it as a startup command, whith the following parameters:
Code:
/home/seth/mirror.sh /home/seth/.opencpn /home/seth/bak &
So what this does is to back up routes, etc as soon as they change, but onto a synchronous journaled file system, which is almost impossible to kill, but very slow. However we are just backing up the routes so it is fine. On the next boot, the backed up routes are copied into the ram disk so all settings persist even though opencpn is running from a ram disk.