pg_dump -U [username] -W -d [database] > /data/backup/[namabackupan].sql
root@ocp-db-01:/data# pg_dump -U postgres -W -d postgres > /data/backup/postgres.sql
Password:
root@ocp-db-01:/data# ls -l
total 24
drwxr-xr-x 2 root     root      4096 Des  8 21:16 backup
drwx------ 2 root     root     16384 Nov 22 01:55 lost+found
drwxr-xr-x 3 postgres postgres  4096 Nov 31 23:03 postgresql
root@ocp-db-01:/data# cd backup/
root@ocp-db-01:/data/backup# ls -l
total 20039124
-rw-r--r-- 1 root root 20520056304 Des  8 21:18 postgres.sql
root@ocp-db-01:/data/backup# ls -aslh
total 20G
4.0K drwxr-xr-x 2 root root 4.0K Des  8 21:16 .
4.0K drwxr-xr-x 5 root root 4.0K Des  8 16:37 ..
 20G -rw-r--r-- 1 root root  20G Des  8 21:18 postgres.sql
root@ocp-db-01:/data/backup#
psql -U [username] -d [databasetujuan] -1 -f /tmp/[namadatabase].sql

postgres=# \l
                                    List of databases
     Name      |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
---------------+----------+----------+-------------+-------------+-----------------------
 dbcloningan   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 dbtes         | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 posgres-clone | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 postgres      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
 template1     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
(6 rows)

postgres=# exit
postgres@ocp-db-dev-01:~$ psql -U postgres -d posgres-clone -1 -f /tmp/postgres.sql
SET
SET
SET
SET
SET
 set_config
------------

(1 row)

SET
SET
....
....

Leave a Reply

Your email address will not be published. Required fields are marked *