From 18d6f6951e268b9d7018fe6093f4b8917a5c42c2 Mon Sep 17 00:00:00 2001 From: Morgan Date: Sat, 12 Oct 2019 14:10:18 +0200 Subject: [PATCH] Creating a copy of a database in PostgreSQL. --- cheat/postgresql.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cheat/postgresql.md b/cheat/postgresql.md index 0ebc3b9..9894935 100644 --- a/cheat/postgresql.md +++ b/cheat/postgresql.md @@ -54,3 +54,9 @@ If you're using CLI and you're a postgres user, then you can do this: `psql -c "SELECT version();"` + +### Creating a copy of a database in PostgreSQL. +``` +pg_dumpall > db.out # backup +psql -f db.out postgres # restore (might requires some DROP DATABASE xxx if you do want to replace existing data with same db and table names. +```