Today is my lucky backup day.
TLDR; restored ~ 1 year of analytics data for Plausible analytics.
I really do care about my data, but apparently not enough to have a proper backup strategy.
That’s at least what this lesson taught me.
So let me elaborate/rant a bit.
I am using a simple Ansible playbook to provision my server with all the stuff that it needs, e.g. hardening, self-hosted services mostly with docker, nginx reverse proxy, vpn, etc.
You can already see there’s the something missing about “backup/restore” in the playbook… But I’m getting ahead of myself.
For Plausible, I am using the official docker-compose setup from the hosting repository. The docs are the best in town and are simple to follow.
On January 25th, that tragic day that cost me a whole lot of nerves, I was doing some maintenance on my server.
Checking out the Ansible playbook, browsing around files and setting to see if I could update or improve something.
Then after some cleanup, I run my usual ansible-playbook playbook.yml
command and boom.
Something went wrong. Some nginx directive was wrong (totally unrelated to Plausible).
Fix it, run it again, everything ok.
Except all my Plausible data was “gone”, apparently.
It was showing “0 visitors” for the last 24 hours.
“Oh oh, weird”, I thought.
Checking the monthly chart, also 0 visitors.
Oh shit.
I want to dedicate this section to all data lost and the poor souls that suffered from it.
Then after sleeping on it, I found out there were other people in the same boat.
After following this discussion about upgrading to 2.0.0, I successfully restored all my data.
Even though I wasn’t even upgrading to 2.0.0
It was simple a minor update.
The following did the trick for me:
$ docker compose stop plausible plausible_events_db
$ docker compose rm plausible_events_db
$ docker compose up -d
$ docker compose stop plausible
$ docker compose rm plausible
$ docker compose up -d
$ docker compose exec plausible bin/plausible rpc Plausible.DataMigration.NumericIDs.run
Here you can find the official upgrade guide for postgres
So today, January 26th, marks the date for my personal Happy Lucky Backup Day 😅
(Alongside the World Backup Day on March 31st)