Posts

Showing posts with the label PostgreSQL

FreeBSD: Install PostgreSQL Server & Client

1.At first update the server’s repository information. $ sudo pkg update 2.Search PostgreSQL in PKG. $ pkg search postgresql 3.Install the last version PostgreSQL. $ sudo pkg install postgresql10-server Sample Output: Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. The following 5 package(s) will be affected (of 0 checked): New packages to be INSTALLED: postgresql10-server: 10.1 libxml2: 2.9.4 postgresql10-client: 10.1 perl5: 5.24.3 readline: 7.0.3 Number of packages to be installed: 5 The process will require 88 MiB more space. 21 MiB to be downloaded. Proceed with this action? [y/N]: y [1/5] Fetching postgresql10-server-10.1.txz: 100% 4 MiB 4.1MB/s 00:01 [2/5] Fetching libxml2-2.9.4.txz: 100% 802 KiB 820.8kB/s 00:01 [3/5] Fetching postgresql10-client-10.1.txz: 100% 2 MiB 2.6MB/s 00:01 [4/5] Fetching perl5-5.24.3.txz: 100% 13 MiB 14.0MB/s 00:01 [5/5] Fetching readlin...

PostgreSQL: Backup and Restore(large databases)

For very large databases, you might need to combine split with one of the other two approaches. 1. nohup pg_dump -h 192.168.x.x -d dbname -U username -Fc > filename.dmp 2>&1 & -F format (--c custom) A custom-format dump is not a script for psql, but instead must be restored with pg_restore, for example: $ dropdb mydb $ pg_restore -C -d postgres db.dump $ createdb -T template0 newdb $ pg_restore -d newdb db.dump 2. nohup pg_restore -C -d newdb filename.dmp 2>&1 & -C --create Create the database before restoring into it. -d dbname --dbname=dbname -O --no-owner Do not output commands to set ownership of objects to match the original database. By default, pg_restore issues ALTER OWNER or SET SESSION AUTHORIZATION statements to set ownership of created schema elements. These statements will fail unless the initial connection to the database is made by a superuser (or the same user that owns all of the objects in the script). With -O, any user n...