RetroFed Forums
Your home away from modern life.
Backing up PieFed instance?
Post Reply
AuthorMessage
Phoenix1 piefed.social Phoenix1@piefed.social
Joined: 2026-01-09
Quote

Hello! I've recently been testing out PieFed (I followed the Docker install instructions), it's actually working quite well... However, I'm a bit of a newbie system administrator, I was wondering if there was a guide or documentation available on how to back up/restore a PieFed instance installed this way? Being able to back up and restore the instance is the one stumbling block I need to get past in order to self host PieFed, so I would certainly appreciate any help that people can provide 😀 Thanks!

1   Original
asudox lemmy.asudox.dev asudox@lemmy.asudox.dev
Joined: 2025-01-18
#2 · Quote Reply

Just dump the entire db

1
Phoenix1 piefed.social Phoenix1@piefed.social
Joined: 2026-01-09
#3 · Quote Reply

Just dump the entire db

Thanks, that should be simple to figure out if it's just one step, although I've never dumped a database from a Docker image before...I'll have to do some searching and see if I can figure it out!

1
hendrik palaver.p3x.de hendrik@palaver.p3x.de
Joined: 2021-08-21
#4 · Quote Reply

Thanks, that should be simple to figure out if it's just one step, although I've never dumped a database from a Docker image before...I'll have to do some searching and see if I can figure it out!

In addition to the DB, there's also a media directory with a lot of stuff like images. I guess that should be saved as well. Not sure how that's done with Docker but I'm sure it has some mechanism to back up volumes. It's called "media" in the docker compose file, or "app/static/media/" in my non-containerized install.

1
Phoenix1 piefed.social Phoenix1@piefed.social
Joined: 2026-01-09
#5 · Quote Reply

In addition to the DB, there's also a media directory with a lot of stuff like images. I guess that should be saved as well. Not sure how that's done with Docker but I'm sure it has some mechanism to back up volumes. It's called "media" in the docker compose file, or "app/static/media/" in my non-containerized install.

Unfortunately I haven't been able to figure this out, I was able to write a script for Mastodon that automated the process of dumping the database, copying the system folder and so on, I was able to restore a test backup I made successfully as well. I only say that to indicate that I have at least some familiarity with the shell, but not much 😁 In the case of Mastodon it's running on "bare metal" so to speak rather than Docker, so this is probably much easier for someone who is familiar with Docker!

1
Rimu Moderator rimu@piefed.social
Joined: 2024-01-04
#6 · Quote Reply

Unfortunately I haven't been able to figure this out, I was able to write a script for Mastodon that automated the process of dumping the database, copying the system folder and so on, I was able to restore a test backup I made successfully as well. I only say that to indicate that I have at least some familiarity with the shell, but not much 😁 In the case of Mastodon it's running on "bare meta...

You could use PieFed in docker with the DB connection set in .env.docker in such a way that it connects to a database on the host. That'd be easier to get to.

1
wjs018 piefed.wjs018.xyz wjs018@piefed.wjs018.xyz
Joined: 2025-07-15
#7 · Quote Reply

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.

1
HubertManne piefed.social HubertManne@piefed.social
Joined: 2025-03-13
#8 · Quote Reply

why haven't we patriated all russian assets we have frozen?

1
Phoenix1 piefed.social Phoenix1@piefed.social
Joined: 2026-01-09
#9 · Quote Reply

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 stac...

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!

1
wjs018 piefed.wjs018.xyz wjs018@piefed.wjs018.xyz
Joined: 2025-07-15
#10 · Quote Reply

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 reall...

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
1
Phoenix1 piefed.social Phoenix1@piefed.social
Joined: 2026-01-09
#11 · Quote Reply

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 ...

I'd like to thank you very much for this, it's easy to follow and it explains each of the steps well! I will go about turning this into a script for cron!

1
erebion news.erebion.eu erebion@news.erebion.eu
Joined: 2025-11-20
#12 · Quote Reply

Thanks, that should be simple to figure out if it's just one step, although I've never dumped a database from a Docker image before...I'll have to do some searching and see if I can figure it out!

While you're figuring that out: Just stop Piefed and backup all the files. This works while you're building a better solution. For my whole server with more stuff it's just a minute for the full backup and I wouldn't mind a minute of downtime in the middle of the night.

1
Post Reply
Back to top