zoukankan      html  css  js  c++  java
  • PostgreSQL完整备份与还原过程

    1. 备份10.12.2.100PC机(服务器)上的数据库(仅备份数据库和对应的数据库里面各表的结构):
     pg_dump -h 10.12.2.100 -U postgres -p 8101 -d tianrun -s -f /data/tianrun0115.backup
    2. 备份10.12.2.100PC机(服务器)上的数据库:
     nohup pg_dump -h 10.12.2.100 -U postgres -p 8101 -d tianrun -w -F c -b -v -f /data/tianrun0115.backup &
    3.在备份好的数据库文件所在的PC机(服务器1)传输备份数据库至目标PC机(服务器2):
       scp -r /opt/goldwind/pgdata/tianrun0114.backup goldwind@10.12.2.135:/data/
    4.在目标PC机(服务器2)执行恢复数据库命令:(执行时,需要有一存在的命名为tianrun0115的空库)
       nohup pg_restore -h 10.12.2.135 -p 8101 -U postgres -W -d tianrun -v "/data/tianrun0115.backup"

    5. 查看日志是否正常输出:tail -f nohup.out

    6.进入tianrun0115数据库:
       [goldwind@TR-OS-DB ~]$ psql -h 10.12.2.135 -p 8101 -U postgres -W -d tianrun0115

    7. 命令修改数据库名称:
       UPDATE pg_database SET datname = 'newDBname' where datname = 'oldDBname';

    8. 立即停止PostgreSQL数据库服务
        pg_ctl stop -m fast
    9. 启动PostgreSQL数据库服务
        pg_ctl start -D /data/pgdata/9.4/

  • 相关阅读:
    ixgbe dma 控制器
    per cpu
    HDU 4597 Play Game
    HDU 5115 Dire Wolf
    hdu 5900 QSC and Master
    CodeForces933A A Twisty Movement
    CodeForces 245H Queries for Number of Palindromes
    CodeForces596D Wilbur and Trees
    CodeForces509F Progress Monitoring
    CodeForces149D Coloring Brackets
  • 原文地址:https://www.cnblogs.com/ylq1990/p/10283136.html
Copyright © 2011-2022 走看看