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