PostgreSQL database
GoBackup use pg_dump
utility to backup PostgreSQL database into a .sql
file.
If your host not have pg_dump
you need install it first.
NOTE: PostgreSQL requirement pg_dump have a same version with server, so if your PostgreSQL server,you can follow this guides to install same version of
postgresql-contrib
:
- Ubuntu: https://www.postgresql.org/download/linux/ubuntu/
- Red Hat / CentOS: https://www.postgresql.org/download/linux/redhat/
Follow the guides to Install the repository RPM, and then run:
# For Ubuntu
$ sudo apt-get install postgresql10-contrib
# For Red Hat
$ sudo yum install postgresql10-contrib
# For AlpineLinux
$ apk add postgresql-client
Database config keys
type: postgresql
host
- server host, default:localhost
port
- server port, default:5432
database
- database nameusername
- default:root
password
https://github.com/huacnlee/gobackup/blob/master/database/postgresql.go
Restore Database
$ psql -U postgres -d your-database -f /path/to/your-backup.sql