oracle 19c pdb备份脚本(多个pdb)

1.配置PDB tns,注意如果是rac,这个备份应该只写当前节点ip

  如果是写scanip 可能会连接到其他节点,从而报无权限的问题

  配置好tnsping 一下 确认都可以正常连通

2.连接到各个pdb 创建专门的备份用户

alter session set container=pdb1;

创建用户 和备份目录 并赋权

create user backup identified by xxxx;

create directory expdir as '/oradata/backup/';

grant connect,resource,dba to backup;

grant read,write on directory expdir to backup;

3.统一的多pdb备份脚本
#!/bin/bash
#create by fan 20230209
PATH=$PATH:$HOME/bin
ORACLE_HOME=/u01/app/oracle/product/19.0.0.0/dbhome_1
ORACLE_SID=orcl
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID
export PATH
export BACKUPTIME=`date +%Y%m%d%H%M%S`
expdp backup/xxxxx@pdb1 directory = expdir dumpfile=pdb1$BACKUPTIME.dmp logfile=pdb1$BACKUPTIME.log full=y
expdp backup/xxxxx@pdb2 directory = expdir dumpfile=pdb2$BACKUPTIME.dmp logfile=pdb2$BACKUPTIME.log full=y
expdp backup/xxxxx@pdb3 directory = expdir dumpfile=pdb3$BACKUPTIME.dmp logfile=pdb3$BACKUPTIME.log full=y
##delete old dump
find /oradata/backup/ -mtime +7 -name *.dmp -exec rm -f {} ';'
find /oradata/backup/ -mtime +7 -name *.log -exec rm -f {} ';'

你可能感兴趣的:(oracle,案例解决,oracle,DBA,oracle,数据库)