Story about wiped out database or 2 lines of code.
volumes:
- postgres_data:/var/lib/postgresql/data
Lessons from a Wiped-Out Database: Building a Crypto Portfolio Tracker
I’m currently working on a Crypto Portfolio Tracker — a personal project aimed at simplifying how I manage my crypto investments. Previously, I tracked transactions using NextCloud spreadsheets and custom macros to fetch real-time prices. However, this approach quickly became cumbersome. To streamline the process, I decided to build a Django application backed by a PostgreSQL database.
After making solid progress, I deployed the app on my home server (Orange Pi 5) using Docker Compose. The initial deployment went smoothly, and the app was functioning as expected. I used it for a while, fixed a few bugs, and then rebuilt the Docker container.
That’s when I noticed a critical issue: my PostgreSQL database was completely empty.
The culprit? I had forgotten to configure a dedicated Docker volume for PostgreSQL. As a result, every time the container was rebuilt, the database data was wiped.
Key Takeaways (a.k.a. Hard-Earned Lessons):
- Always back up your database before making significant changes.
- Understand how Docker volumes work—they’re essential for persistent data storage.
- Don’t skip infrastructure planning, even for personal projects.
This experience significantly deepened my understanding of Docker’s inner workings. As part of the recovery and improvement process, I also added a pgAdmin container to manage the PostgreSQL database through a web interface, making debugging and data management much easier.