当前位置:网站首页>Gbase8s core data backup
Gbase8s core data backup
2022-07-29 10:59:00 【wangwei830】
GBase8s Core data backup
The purpose of this tool : Sometimes customers don't back up , It is too difficult and time-consuming to repair the database when it goes wrong . This tool is to quickly deal with the fault and resume production this morning .
Backup items
Reserved page
pe
onstat -d
onstat -l
partation page
dbschema
The system tables :sysdatabses,systabnames,systables
Backup steps
Backup retention page
oncheck -pr > pr
rootpath=$(onstat -d |awk '$2==1 && $3==1 {print $NF}' )
rootpgsize=$(onstat -d |awk '$2==1 && $4==1 {print $6}')
dd if=$rootpath of=pr0 skip=0 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr1 skip=1 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr2 skip=2 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr3 skip=3 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr4 skip=4 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr5 skip=5 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr6 skip=6 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr7 skip=7 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr8 skip=8 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr9 skip=9 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr10 skip=10 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr11 skip=11 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr12 skip=12 seek=0 bs=$rootpgsize count=1
Backup pe
oncheck -pe > pe
tmpdbs=$(onstat -d |grep "TBA" |awk '{printf("%s|",$NF)}'|sed 's/|$//')
cat pe |grep -E "TBLSpace| \/" |grep -vE "$tmpdbs" |grep -v "DBspace Usage"|awk '{ if ($2~/\//){path=$2; pgsize=$3*1024} if ($1~/TBLSpace/) {print path,pgsize,$2,$3} }' > TBLSpace.list
cat TBLSpace.list |while read path pgsize begin len
do
i=$begin
let end=${begin}+${len}
name=$(echo $path|awk -F '/' '{print $NF}')
while [ $i -lt $end ]; do
dd if=$path of=${name}_${i} skip=$i seek=0 bs=$pgsize count=1
let i=$i+1
done
done
Backup onstat -d
onstat -d > on_d
Backup onstat -l
onstat -l > on_l
onstat -c > on_c
onstat -g env > on_env
Backup sysdatabases
echo "unload to masterDatabas.unl select * from sysdatabases;" |dbaccess sysmaster
echo "unload to masterDblocal.unl select * from sysdbslocale;" |dbaccess sysmaster
Backup systabnames
echo "unload to masterTabnames.unl select * from systabnames;" |dbaccess sysmaster
Backup library structure dbschema and systables
cat masterDatabas.unl | awk -F \| '{print $1}' |while read dbname
do
dbschema -d $dbname -ss SQL_${dbname}.sql
echo "unload to Tables_${dbname}.unl select * from systables;" |dbaccess $dbname
done
Merge script versions Back up core data
#!/bin/bash
onmode -c
# Reserved page
oncheck -pr > pr
rootpath=$(onstat -d |awk '$2==1 && $3==1 {print $NF}' )
rootpgsize=$(onstat -d |awk '$2==1 && $4==1 {print $6}')
dd if=$rootpath of=pr0 skip=0 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr1 skip=1 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr2 skip=2 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr3 skip=3 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr4 skip=4 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr5 skip=5 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr6 skip=6 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr7 skip=7 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr8 skip=8 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr9 skip=9 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr10 skip=10 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr11 skip=11 seek=0 bs=$rootpgsize count=1
dd if=$rootpath of=pr12 skip=12 seek=0 bs=$rootpgsize count=1
#pe and patration
oncheck -pe > pe
tmpdbs=$(onstat -d |grep "TBA" |awk '{printf("%s|",$NF)}'|sed 's/|$//')
cat pe |grep -E "TBLSpace| \/" |grep -vE "$tmpdbs" |grep -v "DBspace Usage"|awk '{ if ($2~/\//){path=$2; pgsize=$3*1024} if ($1~/TBLSpace/) {print path,pgsize,$2,$3} }' > TBLSpace.list
cat TBLSpace.list |while read path pgsize begin len
do
i=$begin
let end=${begin}+${len}
name=$(echo $path|awk -F '/' '{print $NF}')
while [ $i -lt $end ]; do
dd if=$path of=${name}_${i} skip=$i seek=0 bs=$pgsize count=1
let i=$i+1
done
done
# Environmental Science
onstat -d > on_d
onstat -l > on_l
onstat -c > on_c
onstat -g env > on_env
# Global Library
echo "unload to masterDatabas.unl select * from sysdatabases;" |dbaccess sysmaster
echo "unload to masterDblocal.unl select * from sysdbslocale;" |dbaccess sysmaster
echo "unload to masterTabnames.unl select * from systabnames;" |dbaccess sysmaster
# Each library
cat masterDatabas.unl | awk -F \| '{print $1}' |while read dbname
do
dbschema -d $dbname -ss SQL_${dbname}.sql
echo "unload to Tables_${dbname}.unl select * from systables;" |dbaccess $dbname
done
C Language version dumpTBLSall page
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char* itoa(int num,char* str,int radix)
{
char index[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
unsigned unum;
int i=0,j,k;
if(radix==10&&num<0)
{
unum=(unsigned)-num;
str[i++]='-';
}
else unum=(unsigned)num;
do
{
str[i++]=index[unum%(unsigned)radix];
unum/=radix;
}while(unum);
str[i]='\0';
if(str[0]=='-') k=1;
else k=0;
char temp;
for(j=k;j<=(i-1)/2;j++)
{
temp=str[j];
str[j]=str[i-1+k-j];
str[i-1+k-j]=temp;
}
return str;
}
void writePE(){
system("oncheck -pe > pe ; sleep 1");
}
void wstrtok(char *str, char s[2], int n, char *list[]){
int i = 0;
list[0]=strtok(str,s);
while(list[i] != NULL){
list[++i] = strtok(NULL,s);
}
for(i=0; i<n; i++){
if(list[i] != NULL){
//printf("%d: %s\n",i,list[i]);
}
}
}
void dumpAllTBLS(){
FILE *pe;
pe = fopen("pe","r");
if (pe == NULL){
fputs(" Error opening file !\n",stderr);
exit(1);
}
char h[1024];
char path[200];
int pgsize;
int begin ;
int lens ;
while (!feof(pe)){
fgets(h,1025,pe);
if( ferror(pe) ){
break;
}
if(strstr(h,"TBLSpace") || strstr(h," /")){
if(!strstr(h,"(0x")){
if(strstr(h," /")){
char *list[6];
wstrtok(h," ",6,list);
strcpy(path,list[1]);
pgsize = atoi(list[2]);
}
if(strstr(h,"TBLSpace")){
//printf("%s",h);
char *ltbl[3];
wstrtok(h," ",3,ltbl);
begin = atoi(ltbl[1]);
lens = atoi(ltbl[2]);
printf("#%s %d %d %d\n",path,pgsize,begin,lens);
int i = begin;
int end = begin + lens;
char string[1024] ;
strcpy(string,path);
const char sd[2] = "/";
char *name;
char *lastname;
name = strtok(string,sd);
while( name != NULL ){
lastname=name;
name = strtok(NULL,sd);
}
strcat(lastname,"_");
//printf("%s====%s=====%s====\n",name,lastname,path);
char strc[200] = {
0} ;
char strt[200] = {
0} ;
char pgsizes[20] ;
char is[20];
system("mkdir -p pag; mkdir -p txt; ");
//itoa(pgsize,pgsizes,16);
sprintf(pgsizes,"%d",pgsize*1024);
while ( i < end ){
//itoa(i,is,16);
sprintf(is,"%d",i);
strcpy(strc,"dd if=");
strcat(strc,path);
strcat(strc," of=pag/");
strcat(strc,lastname);
strcat(strc,is);
strcat(strc," skip=");
strcat(strc,is);
strcat(strc," bs=");
strcat(strc,pgsizes);
strcat(strc," count=1");
//printf("%s\n",strc);
system(strc);
strcpy(strt,"xxd pag/");
strcat(strt,lastname);
strcat(strt,is);
strcat(strt," > txt/");
strcat(strt,lastname);
strcat(strt,is);
strcat(strt,".txt");
//printf("%s\n",strt);
system(strt);
i++;
}
}
}
}
}
}
int main(){
writePE();
dumpAllTBLS();
system("tar -zcvf pag.tar.gz pag/");
system("tar -zcvf txt.tar.gz txt/");
return 0;
}
边栏推荐
- 深入理解C# 可空类型
- Hugo NexT V4 介绍
- 报表控件FastReport与StimulSoft功能对比
- js两个数组对象进行合并去重
- 北京大学公开课重磅来袭!欢迎走进「AI for Science」课堂
- QWidget、QDialog、QMainWindow 的异同点
- Alibaba architects spent a year sorting out the "Lucene advanced document", and you are also a big factory employee!
- StarRocks 技术内幕:实时更新与极速查询如何兼得
- SkiaSharp 之 WPF 自绘 弹动小球(案例版)
- Leetcode binary tree series -- 144. Preorder traversal of binary trees
猜你喜欢
IPV6基础
QT's user-defined interface (borderless and movable)
开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览
自采集在线电脑壁纸php源码v2.0自适应端
Watch the open source summit first | quick view of the sub Forum & Activity agenda on July 29
Niuke net brush questions
Qt 之自定义界面(实现无边框、可移动)
基于flask写的一个小商城mall项目
报表控件FastReport与StimulSoft功能对比
Lucky draw system with background source code
随机推荐
One click blog building: how to use WordPress plug-in to build a dedicated blog
周鸿祎:360是世界上最大的安全大数据公司
QWidget、QDialog、QMainWindow 的异同点
IPv6 Foundation
Sunwenlong, Secretary General of the open atom open source foundation, worked together to expand open source
2.安装MySQL
Exclusive interview | Cheng Li, chief technology officer of Alibaba: cloud + open source together form a credible foundation for the digital world
Meituan and hungry were interviewed by Hangzhou supervisors to implement the responsibility of food safety management and prohibit malicious competition
JVM知识点详细整理(长文警告)
How to realize the function of adding watermark
Self collection online computer wallpaper PHP source code v2.0 adaptive end
Kunlunbase instruction manual (II) best practices for peer-to-peer deployment
Detailed arrangement of JVM knowledge points (long text warning)
R language Monte Carlo method and average method are used to calculate the definite integral. Considering the random point casting method, the confidence is 0.05, and the requirement is ϵ= 0.01, numbe
Add: create Ou structure using PowerShell
Conference OA project - my approval
GBase8s核心数据备份
Luogu p1816 loyalty solution
TCP and UDP
浅谈string中的compareTo方法