Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3127835
  • 博文数量: 206
  • 博客积分: 3409
  • 博客等级: 中校
  • 技术积分: 4066
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-24 10:21
个人简介

● ITPUB名人堂嘉宾 ● ChinaUnix社区博客专家 ● ChinaUnix社区Oracle板块版主 ● 优酷网认证音乐牛人:EricGuitar ● SDOUG 核心成员 ●E-mail:gaoqiangdba@163.com

文章分类

全部博文(206)

文章存档

2021年(11)

2020年(7)

2019年(7)

2016年(5)

2015年(36)

2014年(23)

2013年(15)

2012年(23)

2011年(61)

2010年(18)

分类: Mysql/postgreSQL

2015-02-28 10:20:05

  

进行一次全备:
-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman backup --backup-mode=full
INFO: database backup start
NOTICE:  pg_stop_backup complete, all required WAL segments have been archived




进行一次增备:
-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman backup --backup-mode=incremental
INFO: database backup start
NOTICE:  pg_stop_backup complete, all required WAL segments have been archived




查看备份信息:
-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman show timeline
============================================================
Start                Mode  Current TLI  Parent TLI  Status  
============================================================
2015-02-27 17:46:12  INCR            1           0  DONE
2015-02-27 17:45:01  FULL            1           0  DONE
2015-02-26 00:22:13  INCR            1           0  OK
2015-02-26 00:19:10  FULL            1           0  OK


-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman show
============================================================================
Start                Time   Total    Data     WAL     Log  Backup   Status  
============================================================================
2015-02-27 17:46:12    0m    ----   290kB    83MB    ----    84MB   DONE
2015-02-27 17:45:01    0m    28MB    ----    50MB    ----    76MB   DONE
2015-02-26 00:22:13    0m    ----    16kB    67MB      0B    67MB   OK
2015-02-26 00:19:10    0m    28MB    ----   117MB   3704B   143MB   OK




查看数据库内的测试数据情况:
-bash-4.1$ psql music
psql (9.4.1)
Type "help" for help.


music=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 music     | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(4 rows)




music=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | test | table | postgres
(1 row)




删除表格:
music=# drop table test;
DROP TABLE
music=# \d
No relations found.      ---测试数据已删除
music=# \q


-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman validate


-bash-4.1$ /usr/pgsql-9.4/bin/pg_ctl stop -m fast
waiting for server to shut down.... done
server stopped




基于时间点恢复数据库:
-bash-4.1$  /usr/pgsql-9.4/bin/pg_rman restore -B /pgbackup --recovery-target-time  2015-02-27
INFO: validate: 2015-02-26 00:19:10 backup and archive log files by SIZE
INFO: validate: 2015-02-26 00:22:13 backup and archive log files by SIZE
INFO: validate: 2015-02-26 00:22:13 server log files by SIZE
INFO: restore complete. Recovery starts automatically when the PostgreSQL server is started.








启动数据库后查看数据是否已恢复:
-bash-4.1$ psql music
psql (9.4.1)
Type "help" for help.


music=# \d
        List of relations
 Schema | Name | Type  |  Owner   
--------+------+-------+----------
 public | test | table | postgres
(1 row)


music=# select * from test;
 id 
----
  1
  2
  3
(3 rows)


OK,数据已恢复!~~~
阅读(7630) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~