From a9e5537bb117f6592524910102737f8d5382fca0 Mon Sep 17 00:00:00 2001 From: "Mariana R. Santos" Date: Thu, 24 Oct 2024 14:40:31 +0200 Subject: [PATCH] Update database section on readme --- backend/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backend/README.md b/backend/README.md index 7750b2b5d..a92d0fc10 100644 --- a/backend/README.md +++ b/backend/README.md @@ -231,6 +231,28 @@ Example: ); ``` +## Database backup and cloning + +You can use pg_dump to extract a PostgreSQL database into an sql file and psql to import the data into the target database from that file. Have the server running on pgAdmin and then execute the following commands. + +Extract the entire database: + +``` +pg_dump -U Username -d postgres -h host name/adress -p 5432 -f ouput_file_name.slq +``` + +Extract specific tables: + +``` +pg_dump -U Username -d postgres -h host_name_or_adress -p 5432 -t '"table_name"' -t '"second_table_name"' -f input_file_name.slq +``` + +Upload file information to new database: + +``` +psql U Username -d postgres -h host_name/adress -p 5432 -f ouput_file_name.slq +``` + ## Formatting ### CSharpier