summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-03 14:37:44 -0400
committerDessalines <tyhou13@gmx.com>2020-04-03 14:37:44 -0400
commit522299ea9eeee8b475080eb81805c55161d90baa (patch)
tree9413416115badefe938ae657f6bef0f8efcea5a1 /docs
parent0ca385deaf00d905081c66d0e0164558531e0e70 (diff)
Adding docs for DB Backup / Restore. Fixes #619
Diffstat (limited to 'docs')
-rw-r--r--docs/src/SUMMARY.md1
-rw-r--r--docs/src/about_goals.md1
-rw-r--r--docs/src/administration_backup_and_restore.md44
3 files changed, 46 insertions, 0 deletions
diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md
index 70c423c7..bff5cbf6 100644
--- a/docs/src/SUMMARY.md
+++ b/docs/src/SUMMARY.md
@@ -10,6 +10,7 @@
- [Install with Ansible](administration_install_ansible.md)
- [Install with Kubernetes](administration_install_kubernetes.md)
- [Configuration](administration_configuration.md)
+ - [Backup and Restore](administration_backup_and_restore.md)
- [Contributing](contributing.md)
- [Docker Development](contributing_docker_development.md)
- [Local Development](contributing_local_development.md)
diff --git a/docs/src/about_goals.md b/docs/src/about_goals.md
index caa6948a..e0427481 100644
--- a/docs/src/about_goals.md
+++ b/docs/src/about_goals.md
@@ -51,3 +51,4 @@
- [Activitypub implementers guide](https://socialhub.activitypub.rocks/t/draft-guide-for-new-activitypub-implementers/479)
- [Data storage questions](https://socialhub.activitypub.rocks/t/data-storage-questions/579/3)
- [Activitypub as it has been understood](https://flak.tedunangst.com/post/ActivityPub-as-it-has-been-understood)
+- [Asonix http signatures in rust](https://git.asonix.dog/Aardwolf/http-signature-normalization)
diff --git a/docs/src/administration_backup_and_restore.md b/docs/src/administration_backup_and_restore.md
new file mode 100644
index 00000000..fe97cf88
--- /dev/null
+++ b/docs/src/administration_backup_and_restore.md
@@ -0,0 +1,44 @@
+# Backup and Restore Guide
+
+## Docker and Ansible
+
+When using docker or ansible, there should be a `volumes` folder, which contains both the database, and all the pictures. Copy this folder to the new instance to restore your data.
+
+### Incremental Database backup
+
+To incrementally backup the DB to an `.sql` file, you can run:
+
+```bash
+docker exec -t FOLDERNAME_postgres_1 pg_dumpall -c -U lemmy > lemmy_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql
+```
+### A Sample backup script
+
+```bash
+#!/bin/sh
+# DB Backup
+ssh MY_USER@MY_IP "docker exec -t FOLDERNAME_postgres_1 pg_dumpall -c -U lemmy" > ~/BACKUP_LOCATION/INSTANCE_NAME_dump_`date +%Y-%m-%d"_"%H_%M_%S`.sql
+
+# Volumes folder Backup
+rsync -avP -zz --rsync-path="sudo rsync" MY_USER@MY_IP:/LEMMY_LOCATION/volumes ~/BACKUP_LOCATION/FOLDERNAME
+```
+
+### Restoring the DB
+
+If you need to restore from a `pg_dumpall` file, you need to first clear out your existing database
+
+```bash
+# Drop the existing DB
+docker exec -i FOLDERNAME_postgres_1 psql -U lemmy -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
+
+# Restore from the .sql backup
+cat db_dump.sql | docker exec -i FOLDERNAME_postgres_1 psql -U lemmy # restores the db
+
+# This also might be necessary when doing a db import with a different password.
+docker exec -i FOLDERNAME_postgres_1 psql -U lemmy -c "alter user lemmy with password 'bleh'"
+```
+
+## More resources
+
+- https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database
+
+