Postgres Database backup:
Pg_dump [OPTION] ... [DBNAME]
/USR/PGSQL-9.4/BIN/PGdump-fc-h 127.0.0.1-upostgres database name >/var/pgsqlback/ruleplatform.sql. '/bin/date + '%Y %b%d%h%m "
#pg_dump is to back up the database directives
#-F Where to put the backup file;
#-h 127.0.0.1 Backup Server IP address
#postgres is the user name of the database
#RulePlatform database name
#> Export Path
Presented in the form of:
/var/pgsqlback/
Database name. sql.2018_jul_01_0500
To recover a database:
Recovery:
/opt/postgresql/9.5/bin/psql-h localhost-u postgres-d DatabaseName </var/pgsqlback/
Database name. sql.2018_jul_01_0500
#psql是恢复数据库命令
#localhost是要恢复到哪个数据库的地址, of course you can write the IP address
#postgres is the user to which database to restore;
#databasename is which database to restore to
Still works on Linux. One notable thing is that if you go directly to the PostgreSQL installation directory bin and execute the command, there may be no pg_dump,psql found, we can do this:
Postgres Database Backup