1. Pg_dump Database Backup Command
/usr/pgsql-9.3/bin/pg_dump-f c-o-u dotop-h 127.0.0.1-p 5432-f/data/erp_data/db_backup/geyt_20170214_09_37_55.sql ge Yt
2.Linux Configuring PostgreSQL automatic backup
Description: Use the system user Dotop to back up the database demo for Dbuser (database user)
1) Create System user DotopAddUser Dotop
2) Create database user Dbuser, create demo database
[[email protected] init.d]# su - postgres
-bash-4.1$ createuser --superuser dbuser
Type "help" Span class= "PLN" > for< Span class= "PLN" > Help .
postgres< Span class= "pun" >=# Alter user dbuser with password dbuser "
postgres=# create database demo with encoding=‘UTF8‘ owner=dbuser;
3) Write the backup script in the Dotop root directory
Enter the following in db_backup.sh: #!/bin/bash/usr/pgsql-9.3/bin/pg_dump-f c-o-u dbuser-h 127.0.0.1-p 5432-f/data/db_backup/demo _$ (date +%y%m%d_%h_%m_%s). SQL Dotopecho "Backup finished" Save, test execution:/home/dotop/db_backup.sh
4) Add automatic execution commandVi/etc/crontab Add the following command to the last line: 2 * * * dotop/home/dotop/db_backup.sh means that the automatic backup task is performed dotop every 2 o'clock in the morning
Linux configuration PostgreSQL Automatic backup