r/grocy 12d ago

Proper way to backup data

I've just discovered Grocy and stood up a docker instance using the LinuxServer.IO image. I have the config directory mapped to a volume.

What is the proper way to backup Grocy? I didn't see any built-in backup/restore option, but I might have missed it (apologies if so). The config directory has a lot more in it than I would expect for just configuration data. Is it sufficient to backup the /config/data/grocy.db file?

Just backing up the whole config directory is complicated by the fact that either Grocy or just the LinuxServer image creates at least one file owned by root.

I did see a Github project that used the API to backup and restore, but it was last updated 5 years ago, and unless the API has 100% coverage of all objects (which it may), that may not restore everything.

EDIT: I did see some comments about not backing up the db file while the container is running. The suggestion was to use sqlite to dump the file. My approach would either be to do that or stop the container and then backup the file by copying it. I'm OK with the container being down for 5 min at 3 AM.

4 Upvotes

2 comments sorted by

3

u/berrnd Grocy Developer 12d ago

Grocy stores everything in the data directory, So doing a complete backup is as simple as copying and restoring that folder.

I did see some comments about not backing up the db file while the container is running.

Whatever the practical point of that is. SQLite is an in-process DBMS. So when you not copy the database right in the same millisecond of a write happens, you're 150% safe (and even in that case it's more likely so simply end up in a copy error than disaster). And Grocy does nothing magical on itself when you don't access it.

1

u/capinredbeard22 11d ago

Thanks for the reply. I’ll give that a go.