Linux configuration PostgreSQL Automatic backup

Source: Internet
Author: User
Tags postgresql psql
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
    • -bash-4.1$ psql
    • psql (9.3.5)
    • 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
    • cd /home/dotop
    • vi db_backup.sh
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

Related Article
Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.