From 0ae1ecd867b3fbc2faef62c81896add027b99562 Mon Sep 17 00:00:00 2001 From: nough Date: Sun, 20 Feb 2022 00:59:56 +0000 Subject: [PATCH 1/4] Update backup.md Added manual backup method first draft --- docs/system/backup.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/system/backup.md b/docs/system/backup.md index b265eeb9c..5e21df679 100644 --- a/docs/system/backup.md +++ b/docs/system/backup.md @@ -25,4 +25,21 @@ They can be found in the mediafiles mounted directory (depending on your install To create a backup of those files simply copy them elsewhere. Do it the other way around for restoring. -The filenames consist of `_`. In case you screw up really badly this can help restore data. \ No newline at end of file +The filenames consist of `_`. In case you screw up really badly this can help restore data. + +## Manual backup from docker build +The standard docker build of tandoor uses postgresql as the back end database. This can be backed up using a function called "dumpall". This effectively generates a list of commands for a postgresql server to use to rebuild your database. You will also need to back up the media files separately. + +Making a full copy of the docker directory can work as a back up, but only if you know you will be using the same hardware, os, and postgresql version upon restore. If not, then the different version of postgresql won't be compatible with the existing tables. + +To back up: +``` +Sudo docker exec -t db_recipes -c -U djangouser +``` + +To restore: +``` +Cat dump.sql | docker exec -i psql postgres -U djangouser +``` +This connects to the postgres table instead of the actual dgangodb table, as the import function needs to delete the table, which can't be dropped off you're connected to it. + From 0697116a21df6a551496f7b58d497d62cfdec1fb Mon Sep 17 00:00:00 2001 From: nough Date: Wed, 6 Jul 2022 19:29:22 +0100 Subject: [PATCH 2/4] Update backup.md Added comment about backing up when other containers are failing --- docs/system/backup.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/system/backup.md b/docs/system/backup.md index 5e21df679..d9bd53ab4 100644 --- a/docs/system/backup.md +++ b/docs/system/backup.md @@ -28,9 +28,10 @@ To create a backup of those files simply copy them elsewhere. Do it the other wa The filenames consist of `_`. In case you screw up really badly this can help restore data. ## Manual backup from docker build -The standard docker build of tandoor uses postgresql as the back end database. This can be backed up using a function called "dumpall". This effectively generates a list of commands for a postgresql server to use to rebuild your database. You will also need to back up the media files separately. +The standard docker build of tandoor uses postgresql as the back end database. This can be backed up using a function called "dumpall". This generates a .SQL file containing a list of commands for a postgresql server to use to rebuild your database. You will also need to back up the media files separately. Making a full copy of the docker directory can work as a back up, but only if you know you will be using the same hardware, os, and postgresql version upon restore. If not, then the different version of postgresql won't be compatible with the existing tables. +You can back up from docker even when the tandoor container is failing, so long as the postgresql database has started successfully. To back up: ``` From 9d381864041021d90e8ff0647a3d8bf78131f810 Mon Sep 17 00:00:00 2001 From: nough Date: Thu, 7 Jul 2022 10:16:52 +0100 Subject: [PATCH 3/4] Update backup.md updated with functional code --- docs/system/backup.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/system/backup.md b/docs/system/backup.md index d9bd53ab4..33a2ef576 100644 --- a/docs/system/backup.md +++ b/docs/system/backup.md @@ -35,12 +35,13 @@ You can back up from docker even when the tandoor container is failing, so long To back up: ``` -Sudo docker exec -t db_recipes -c -U djangouser +sudo docker exec -t docer_db_recipes_1 pg_dumpall -U djangouser > pgdump.sql + ``` To restore: ``` -Cat dump.sql | docker exec -i psql postgres -U djangouser +cat pgdump.sql | docker exec -i psql postgres -U djangouser ``` This connects to the postgres table instead of the actual dgangodb table, as the import function needs to delete the table, which can't be dropped off you're connected to it. From ac25bedddaa8f16423c03d1718ee59f5fe1e833a Mon Sep 17 00:00:00 2001 From: nough Date: Thu, 7 Jul 2022 10:27:32 +0100 Subject: [PATCH 4/4] Update backup.md working restore function --- docs/system/backup.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/system/backup.md b/docs/system/backup.md index 33a2ef576..20e865f9f 100644 --- a/docs/system/backup.md +++ b/docs/system/backup.md @@ -33,15 +33,17 @@ The standard docker build of tandoor uses postgresql as the back end database. T Making a full copy of the docker directory can work as a back up, but only if you know you will be using the same hardware, os, and postgresql version upon restore. If not, then the different version of postgresql won't be compatible with the existing tables. You can back up from docker even when the tandoor container is failing, so long as the postgresql database has started successfully. +the following commands assume that your docker-compose files are in a folder called "docker". replace "docker_db_recipes_1" with the name of your db container. The commands also assume you use a backup name of pgdump.sql. It's a good idea to include a date in this filename, so that successive backups do not get deleted. To back up: ``` -sudo docker exec -t docer_db_recipes_1 pg_dumpall -U djangouser > pgdump.sql +sudo docker exec -t docker_db_recipes_1 pg_dumpall -U djangouser > pgdump.sql ``` To restore: ``` -cat pgdump.sql | docker exec -i psql postgres -U djangouser +cat pgdump.sql | sudo docker exec -i docker_db_recipes_1 psql postgres -U djangouser + ``` This connects to the postgres table instead of the actual dgangodb table, as the import function needs to delete the table, which can't be dropped off you're connected to it.