Just dump the entire db
post
I haven't had to restore from my backup in production yet, but I run two instances and just periodically rsync the mapped volumes to a backup folder. I also use S3 for my media, so it is really just the database that is critical.
Doing dev work, when I know I am about to really fuck up my database doing an experiment, I will rsync myself a backup...blow everything up...tear down the docker stack and swap back in my database folder and it is good to go.
I appreciate all of the advice, it's really just my inexperience that's a problem here. It sounds as if it would be a simple matter of dumping the database from the Docker image and backing up the appropriate directories, but I'm having a heck of a time figuring out how to do that exactly. I'll keep trying though, but if any system admin out there could provide some concrete examples, I'd really appreciate it!
I am not much of a sysadmin either and have had to get help from some other instance admins in the past. Here is the exact process I go through to manually make and then restore a backup. I don't have this automated since I just work in dev environments, but you could put this in a shell script and schedule it with cron or something like that.
Here is how I make the backup (pgdata folder in my case):
# Prerequisite: navigate to the pyfedi folder
# Shut down the docker containers
docker compose down
# Wait for the containers to shut down...
# Then make the backup of the db volume
sudo rsync -a pgdata/ pgdata_backup
And here is how I restore the backup if I mess up my db:
# Again, need to be in the pyfedi folder
# Shut down the docker containers
docker compose down
# Wait for the containers to shut down...
# Delete the messed up db folder
sudo rm -r pgdata
# Rename the backup folder to swap it back in
sudo mv pgdata_backup pgdata
# Start the containers back up
docker compose up -d
all 11 comments