owntracks / recorder

Store and access data published by OwnTracks apps
Other
890 stars 122 forks source link

System of Backup? #490

Closed WGandy closed 1 month ago

WGandy commented 2 months ago

Hello, previous user of owntracks many many years ago. Now I've got a server running and have been using it for about a week. It seems that this will work for what I'm trying to accomplish. But, I haven't found any documentation or discussion around backing up the recorded data. Are there any suggested ways of dealing with this?

jpmens commented 2 months ago

Recorded data is written to files in your configured STORAGE directory, typically /var/spool/owntracks/recorder. It suffices to back up that directory.

To be precise, the data points recorded are in files called YYYY-MM.rec within the rec/<username>/<devicename>/ directory, but the other files in STORAGE you'll also want, e.g. copies of configuration, waypoints, etc.

SiggiKeller commented 1 month ago

Hello, in one of the subdirectories I see also some database files. Is it sufficient to just copy these files? Or is there some particular way to backup the database? Thanks, Siggi

jpmens commented 1 month ago

The ghash directory contains the files you mean. Ideally you stop the Recorder, copy all files under STORAGE, and then restart. With that you'll have all recorded positions, configs, reverse geo data (if you collect it), cards, etc.

Jachimo commented 1 month ago

I do not know if this represents best practice or not, but I have set up a cron job (running under the owntracks user) which syncs the contents of /var/spool/owntracks to a network drive every 5 minutes.

In addition, I have a second cronjob (running under root), which syncs the contents of /usr/local/owntracks/userdata to the same network drive.

In fairness, this is more of a replication / DR strategy rather than a "backup" one, since a malicious program could overwrite the backups. But it protects the data against the VPS suddenly going away, which is what I wanted. For longer-term and more robust backups, something like Borg Backup (which can back up to a remote server over SSH) is what I would consider looking at.

@jpmens in your response you mentioned stopping the recorder... but from what I have seen of the .rec files, it seems like they are written atomically. Is it really necessary to stop the recorder in order to perform a backup? Have I just gotten lucky?

jpmens commented 1 month ago

Backing up the .rec files and other JSON files in the STORAGE directory (/var/spool/owntracks/) is fine. The reason I recommend stopping the Recorder process is so that the reverse-geo LMDB database in ghash/ doesn't remain open, but this should not cause issues.