【GaussDB】gs_dump/gs_restore schema的备份恢复

1.导出db1数据库下schema  public;

gs_dump -U user1 -W User01#123 -f /home/omm/backup/user1/ -p 30100 db1 -n hr -n public -F d 

[omm@gauss001 backup]$ gs_dump -U user1 -W User01#123 -f /home/omm/backup/user1/ -p 30100 db1 -n hr -n public -F d 
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:35]: no matching schemas were found for pattern "hr"
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:39]: The total objects number is 449.
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:39]: [100.00%] 449 objects have been dumped.
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:39]: dump schema hr public successfully
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:39]: dump database db1 successfully
gs_dump[user='user1'][localhost][port='30100'][db1][2024-04-09 14:42:39]: total time: 3819  ms

[omm@gauss001 backup]$ cd user1
[omm@gauss001 user1]$ ll
total 12
-rw------- 1 omm omm   32 Apr  9 14:42 7604.dat.gz
-rw------- 1 omm omm   44 Apr  9 14:42 7605.dat.gz
-rw------- 1 omm omm    0 Apr  9 14:42 dir.lock
-rw------- 1 omm omm 1594 Apr  9 14:42 toc.dat

2.恢复 

db1=> drop table test1; 
DROP TABLE
db1=> drop table test2;
DROP TABLE

--导出的gz压缩文件通过 gs_restore的方式可以导入。
-s:仅仅导入schema;
[omm@gauss001 user1]$ gs_restore -U user1 -W User01#123 /home/omm/backup/user1/ -p 30100 -d db1  -e -c
start restore operation ...
table test1 complete data imported !
table test2 complete data imported !
Finish reading 7 SQL statements!
end restore operation ...
restore operation successful
total time: 45  ms

--清空回收站。
db1=> purge recyclebin;
PURGE RECYCLEBIN
db1=> \d
                                         List of relations
 Schema | Name  | Type  | Owner |                             Storage                              
--------+-------+-------+-------+------------------------------------------------------------------
 public | test1 | table | user1 | {orientation=row,compression=no,storage_type=ustore,segment=off}
 public | test2 | table | user1 | {orientation=row,compression=no,storage_type=ustore,segment=off}
(2 rows)
db1=> select * from test1; 
  1
  2
  3

db1=> select * from test2;
  1 | 薛双奇1
  2 | 薛双奇2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值