暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

openGauss每日一练第20天 |openGauss数据库的逻辑备份与恢复

原创 寒冰 2022-12-13
324

学习目标

掌握openGauss数据库的逻辑备份和恢复技术。

课程作业

1.逻辑备份和恢复案例1:使用sql格式进行备份和恢复omm数据库

 create user test identified by 'huawei@1234';

 create tablespace test_tbs relative location 'tablespace/test_tbs1';

create database testdb with tablespace=test_tbs;

 create table test1(col int);

create table test2(col int);

gsql -d omm -c"\dt"

 gs_dump -U test -W huawei@1234 omm -F p -f /var/lib/opengauss/backup/backup.sql  --我做到这里的时候发生了错误,检查过后发现没有给test 授权。真是大意呀。


 gsql -r

alter user test sysadmin

gs_dump -U test -W huawei@1234 omm -F p -f /var/lib/opengauss/backup/backup.sql

gsql -d testdb -U test -W huawei@1234 -f /var/lib/opengauss/backup/backup.sql

 gsql -d omm -c "\dt"

gsql -d testdb -U test -W huawei@1234 -c "\dt"




2.逻辑备份和恢复案例2:使用dump格式进行备份和恢复omm数据库

create table test3(col int);

 create table test4(col int);

---重新创建两个表区别以前的数据

gs_dump -U test -W huawei@1234 omm -F p -f /var/lib/opengauss/backup/backup.dump  --备份


 gsql -d testdb -U test -W huawei@1234 -f /var/lib/opengauss/backup/backup.dump  --恢复



 gsql -d omm -c "\dt"   --验证

gsql -d testdb -U test -W huawei@1234 -c "\dt"



还有最后一天,在疫情+病情下坚持。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论