Backup support? #61
Replies: 5 comments 1 reply
-
I haven't really had a lot of time to finalize this, but the best I can offer is a script I wrote for this sort of thing. It's pretty solid as far as I can tell: https://github.com/ubergeek77/Lemmy-Easy-Deploy/blob/staging/migrate.sh I don't plan to support rsync, but you can specify a file to dump to. |
Beta Was this translation helpful? Give feedback.
-
Do note, this operates on Docker volumes, not .SQL files. But considering backing up and restoring Lemmy is a single command, and the official Lemmy recommendation is to do exactly that, you seem to have a handle on it. No need to reinvent the wheel! |
Beta Was this translation helpful? Give feedback.
-
Thanks! I'd like to test this on a separate vps instance to see if using the restore worked properly. However, I'm not sure what would happen if I started up a second instance that thought it had the same domain as the first instance. Would it try to federate in a way that confused the way the first one worked? |
Beta Was this translation helpful? Give feedback.
-
Definitely don't load the backup on a domain that doesn't match what's in the backup. I don't know exactly how Lemmy's federation works, but you have the potential to seriously break you instance if you do that, and potentially cause external instances to stop sending you data. |
Beta Was this translation helpful? Give feedback.
-
I tried to use the migrate.sh file but I kept doing something wrong. So now I'm trying to follow the official Lemmy backup and restore procedure. I'm in the live folder but I must have something wrong with this: I also tried: I get the error: What should I do to fix this? |
Beta Was this translation helpful? Give feedback.
-
Lemmy-Easy-Deploy is the best thing ever. I love how easy it is to get things running and do updates.
The only thing missing for me is backups. Currently, I just click a button on my VPS hosting service to backup the entire server, but there's no way to automate that.
And, I haven't figured out how to write a script to do backups. I'm not sure exactly how it'd work with Lemmy-Easy-Deploy, but maybe it could just have an option where you specified a place to rsync the backup to? Or just specify an import or export directory and it'd generate or consume a single compressed file containing everything (database dump, images, etc)?
The closest I've gotten to a backup script is this. But, I can't figure out how to do it without manually copying the container id from the docker ps. Also, I have not attempted to do whatever the restore version of this is, so I'd need to figure out how to run the script dumped by pg_dumpall. Not sure if I could just take the most recent vps backup, then run this the restore there or what. Anyway, any help would be appreciated. How can I improve this? Or, any possibility your script could just do the backup and restore?
now=$(date +"%Y-%m-%d_%H.%M.%S")
cd ~/Lemmy-Easy-Deploy/live
mkdir -p ~/backup/$now/
docker ps
docker container exec <CONTAINER_ID> pg_dumpall -c -U lemmy 1> ~/backup/$now/dump.sql 2> ~/backup/$now/dump.errors
zip -r9 ~/backup/$now/bak-lemmy-volumes.zip /var/lib/docker/volumes --exclude "var/lib/docker/volumes/lemmy-easy-deploy_postgres_data/*"
zip -r9 ~/backup/$now/dump.zip ~/backup/$now/dump.sql
rm ~/backup/$now/dump.sql
Beta Was this translation helpful? Give feedback.
All reactions