2026-03-12 20:51:59
This commit is contained in:
1
bash/Readme.md
Normal file
1
bash/Readme.md
Normal file
@@ -0,0 +1 @@
|
||||
empty
|
||||
16
bash/adrci_purge.sh
Normal file
16
bash/adrci_purge.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
AGE1MIN=0
|
||||
AGE1DAYS=1440
|
||||
AGE7DAYS=10080
|
||||
AGE10DAYS=14400
|
||||
AGE15DAYS=21600
|
||||
AGE30DAYS=43200
|
||||
|
||||
PURGETARGET=$AGE1MIN
|
||||
|
||||
for f in $( adrci exec="show homes" | grep -v "ADR Homes:" );
|
||||
do
|
||||
echo "Purging ${f}:";
|
||||
adrci exec="set home $f; purge -age $PURGETARGET ;" ;
|
||||
done
|
||||
11
bash/backup_tiddly_notes.sh
Normal file
11
bash/backup_tiddly_notes.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
DIR=/app/persistent_docker/tiddlywiki
|
||||
WIKI=mywiki
|
||||
BACKUPDIR=/mnt/yavin4/data/a.Very_Important_Data/backup_TiddlyWiki
|
||||
DATE=`date +%Y-%m-%d_%H-%M`
|
||||
cd ${DIR}
|
||||
tar -cvf - ${WIKI} | gzip > ${BACKUPDIR}/${WIKI}_${DATE}.tar.gz
|
||||
cd ${BACKUPDIR}
|
||||
find ./ -name '${WIKI}*.tar.gz' -mtime +45 -exec rm {} \;
|
||||
|
||||
63
bash/cifs_veracrypt_resilio_start
Normal file
63
bash/cifs_veracrypt_resilio_start
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
URL_ALIVE="https://public.databasepro.fr/.secrets/alive.txt"
|
||||
URL_ENC_PASS="https://public.databasepro.fr/.secrets/linux.txt"
|
||||
SECRET="For#LinuxM1ntVer@crypt"
|
||||
|
||||
|
||||
|
||||
RUNTIME="1 minute"
|
||||
ENDTIME=$(date -ud "$RUNTIME" +%s)
|
||||
|
||||
while [[ $(date -u +%s) -le $ENDTIME ]]
|
||||
do
|
||||
echo -n "`date +%H:%M:%S`: waiting for remote encrypyted password file.. "
|
||||
ALIVE=$(curl -s ${URL_ALIVE})
|
||||
if [ "$ALIVE" == "yes" ]; then
|
||||
echo "OK"
|
||||
break
|
||||
fi
|
||||
echo "retrying in 10 seconds.."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
if [ "$ALIVE" != "yes" ]; then
|
||||
echo "Remote encrypyted password file is not available, giving up"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Get encrypted passwords JSON from URL
|
||||
JSON_ENC_PASS=$(curl -s ${URL_ENC_PASS})
|
||||
|
||||
# Decode JSON
|
||||
ENC_PASS_CIFS=$(jq '.cifs' <<< "${JSON_ENC_PASS}")
|
||||
ENC_PASS_VERACRYPT=$(jq '.veracrypt' <<< "${JSON_ENC_PASS}")
|
||||
|
||||
# Remove first and last double quote from values
|
||||
AUX="${ENC_PASS_CIFS%\"}"
|
||||
AUX="${AUX#\"}"
|
||||
ENC_PASS_CIFS=${AUX}
|
||||
|
||||
AUX="${ENC_PASS_VERACRYPT%\"}"
|
||||
AUX="${AUX#\"}"
|
||||
ENC_PASS_VERACRYPT=${AUX}
|
||||
|
||||
# Uncrypt passwords
|
||||
PASS_CIFS=$(echo ${ENC_PASS_CIFS} | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:${SECRET})
|
||||
PASS_VERACRYPT=$(echo ${ENC_PASS_VERACRYPT} | openssl enc -aes-256-cbc -md sha512 -a -d -pbkdf2 -iter 100000 -salt -pass pass:${SECRET})
|
||||
|
||||
# Mount CIFS
|
||||
sudo mount -t cifs //192.168.0.9/share /mnt/yavin4 -o vers=2.0,uid=smbuser,gid=smbuser,file_mode=0775,dir_mode=0775,user=vplesnila,password=${PASS_CIFS},mfsymlinks
|
||||
|
||||
# Mount Veracrypt volume
|
||||
veracrypt --text --mount /home/vplesnila/data/veracrypt_01.volume /mnt/rslsync --pim 0 --keyfiles "" --protect-hidden no --slot 1 --password ${PASS_VERACRYPT} --verbose
|
||||
|
||||
# Start Resilio Sync
|
||||
systemctl --user start resilio-sync
|
||||
|
||||
# Show FS
|
||||
df -hT
|
||||
|
||||
|
||||
13
bash/cifs_veracrypt_resilio_stop
Normal file
13
bash/cifs_veracrypt_resilio_stop
Normal file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Stop Resilio Sync
|
||||
systemctl --user stop resilio-sync
|
||||
|
||||
# Dismount CIFS
|
||||
sudo umount /mnt/yavin4
|
||||
|
||||
# Dismount Veracrypt volume
|
||||
veracrypt --text --dismount --slot 1
|
||||
|
||||
# Show FS
|
||||
df -hT
|
||||
19
bash/clean_vm.sh
Normal file
19
bash/clean_vm.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
rm -rf /app/oracle/base/admin/*
|
||||
rm -rf /app/oracle/base/dbs/*
|
||||
rm -rf /app/oracle/base/homes/*/dbs/*
|
||||
|
||||
rm -rf /app/oracle/product/11.2/dbs/*
|
||||
rm -rf /app/oracle/product/12.1/dbs/*
|
||||
rm -rf /app/oracle/product/12.2/dbs/*
|
||||
rm -rf /app/oracle/product/19/dbs/*
|
||||
rm -rf /app/oracle/product/21/dbs/*
|
||||
|
||||
rm -rf /data/*
|
||||
rm -rf /reco/*
|
||||
|
||||
rm -rf /home/oracle/oradiag_oracle
|
||||
rm -rf /app/oracle/base/homes/OraDB19Home1/network/admin/*
|
||||
|
||||
> /etc/listener.ora
|
||||
> /etc/tnsnames.ora
|
||||
|
||||
135
bash/crdb.sh
Normal file
135
bash/crdb.sh
Normal file
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: crdb -n|--name <DB_NAME> -v|--version <19|21>"
|
||||
}
|
||||
|
||||
########
|
||||
# MAIN #
|
||||
########
|
||||
|
||||
# parameter processing
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-n | --name ) shift
|
||||
DB_NAME="$1"
|
||||
;;
|
||||
-v | --version ) shift
|
||||
VERSION="$1"
|
||||
;;
|
||||
* ) usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "${DB_NAME}" ] || [ -z "${VERSION}" ]
|
||||
then
|
||||
usage
|
||||
exit -2
|
||||
fi
|
||||
|
||||
# version/template selection
|
||||
if [ "$VERSION" == "21" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET21
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tech/oracle/orabackup/_keep_/Standalone/21
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_BASE}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
if [ "$VERSION" == "19" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET19
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tech/oracle/orabackup/_keep_/Standalone/19
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_BASE}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${BACKUP_DIR}" ]
|
||||
then
|
||||
echo "No template found for this database version"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# admin directories creation
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/adump
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/spfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/divers
|
||||
|
||||
|
||||
# init and spfile creation
|
||||
cp ${BACKUP_DIR}/init${BACKUP_DB_NAME}PRD.ora ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
sed -i -r "s/${BACKUP_DB_NAME}/${DB_NAME}/" ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
|
||||
echo ${ORACLE_SID}
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
create spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora' from pfile='${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora';
|
||||
startup nomount;
|
||||
EOF!
|
||||
|
||||
# duplicate from template
|
||||
rman auxiliary / <<EOF!
|
||||
run
|
||||
{
|
||||
allocate auxiliary channel aux01 device type disk;
|
||||
allocate auxiliary channel aux02 device type disk;
|
||||
allocate auxiliary channel aux03 device type disk;
|
||||
allocate auxiliary channel aux04 device type disk;
|
||||
allocate auxiliary channel aux05 device type disk;
|
||||
allocate auxiliary channel aux06 device type disk;
|
||||
allocate auxiliary channel aux07 device type disk;
|
||||
allocate auxiliary channel aux08 device type disk;
|
||||
allocate auxiliary channel aux09 device type disk;
|
||||
allocate auxiliary channel aux10 device type disk;
|
||||
duplicate target database to ${DB_NAME} backup location '${BACKUP_DIR}/backupset/';
|
||||
}
|
||||
EOF!
|
||||
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
shutdown immediate;
|
||||
startup;
|
||||
EOF!
|
||||
|
||||
# datapatch & recompile
|
||||
cd ${ORACLE_HOME}/OPatch
|
||||
./datapatch
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
-- recompile all in PDB$SEED
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read write instances=ALL;
|
||||
alter session set container=PDB\$SEED;
|
||||
alter session set "_ORACLE_SCRIPT"=true;
|
||||
@?/rdbms/admin/utlrp
|
||||
alter session set "_ORACLE_SCRIPT"=false;
|
||||
alter session set container=CDB\$ROOT;
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read only instances=ALL;
|
||||
EOF!
|
||||
|
||||
# NEWID
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
shutdown immediate;
|
||||
startup mount exclusive;
|
||||
EOF!
|
||||
|
||||
nid TARGET=/ LOGFILE=/tmp/nid.log
|
||||
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
startup mount exclusive;
|
||||
alter database open resetlogs;
|
||||
shutdown immediate;
|
||||
startup;
|
||||
EOF!
|
||||
142
bash/crdb.sh.2024-06-16
Normal file
142
bash/crdb.sh.2024-06-16
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: crdb -n|--name <DB_NAME> -v|--version <11.2.0.4|12.1|12.2|19|21>"
|
||||
}
|
||||
|
||||
########
|
||||
# MAIN #
|
||||
########
|
||||
|
||||
# parameter processing
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-n | --name ) shift
|
||||
DB_NAME="$1"
|
||||
;;
|
||||
-v | --version ) shift
|
||||
VERSION="$1"
|
||||
;;
|
||||
* ) usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "${DB_NAME}" ] || [ -z "${VERSION}" ]
|
||||
then
|
||||
usage
|
||||
exit -2
|
||||
fi
|
||||
|
||||
# version/template selection
|
||||
if [ "$VERSION" == "21" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET21
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/21
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_BASE}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
if [ "$VERSION" == "19" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET19
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/19
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
|
||||
if [ "$VERSION" == "11.2.0.4" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET112
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=WEDGE
|
||||
BACKUP_DIR=/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/11.2.0.4
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${BACKUP_DIR}" ]
|
||||
then
|
||||
echo "No template found for this database version"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# admin directories creation
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/adump
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/spfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/divers
|
||||
|
||||
# not automaticly created in 11.2.0.4
|
||||
mkdir -p /data/${ORACLE_SID}
|
||||
|
||||
# init and spfile creation
|
||||
cp ${BACKUP_DIR}/init${BACKUP_DB_NAME}PRD.ora ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
sed -i -r "s/${BACKUP_DB_NAME}/${DB_NAME}/" ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
|
||||
echo ${ORACLE_SID}
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
create spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora' from pfile='${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora';
|
||||
startup nomount;
|
||||
EOF!
|
||||
|
||||
# duplicate from template
|
||||
rman auxiliary / <<EOF!
|
||||
run
|
||||
{
|
||||
allocate auxiliary channel aux01 device type disk;
|
||||
allocate auxiliary channel aux02 device type disk;
|
||||
allocate auxiliary channel aux03 device type disk;
|
||||
allocate auxiliary channel aux04 device type disk;
|
||||
allocate auxiliary channel aux05 device type disk;
|
||||
allocate auxiliary channel aux06 device type disk;
|
||||
allocate auxiliary channel aux07 device type disk;
|
||||
allocate auxiliary channel aux08 device type disk;
|
||||
allocate auxiliary channel aux09 device type disk;
|
||||
allocate auxiliary channel aux10 device type disk;
|
||||
duplicate target database to ${DB_NAME} backup location '${BACKUP_DIR}/backupset/';
|
||||
}
|
||||
EOF!
|
||||
|
||||
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
shutdown immediate;
|
||||
startup;
|
||||
EOF!
|
||||
|
||||
|
||||
# apply last installed PSU
|
||||
if [ "$VERSION" == "11.2.0.4" ]; then
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
@$ORACLE_HOME/rdbms/admin/catbundle psu apply
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
EOF!
|
||||
else
|
||||
cd ${ORACLE_HOME}/OPatch
|
||||
./datapatch
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
-- recompile all in PDB$SEED
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read write instances=ALL;
|
||||
alter session set container=PDB\$SEED;
|
||||
alter session set "_ORACLE_SCRIPT"=true;
|
||||
@?/rdbms/admin/utlrp
|
||||
alter session set "_ORACLE_SCRIPT"=false;
|
||||
alter session set container=CDB\$ROOT;
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read only instances=ALL;
|
||||
EOF!
|
||||
fi
|
||||
|
||||
135
bash/crdb.sh.2026-02-21
Normal file
135
bash/crdb.sh.2026-02-21
Normal file
@@ -0,0 +1,135 @@
|
||||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: crdb -n|--name <DB_NAME> -v|--version <19|21>"
|
||||
}
|
||||
|
||||
########
|
||||
# MAIN #
|
||||
########
|
||||
|
||||
# parameter processing
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-n | --name ) shift
|
||||
DB_NAME="$1"
|
||||
;;
|
||||
-v | --version ) shift
|
||||
VERSION="$1"
|
||||
;;
|
||||
* ) usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "${DB_NAME}" ] || [ -z "${VERSION}" ]
|
||||
then
|
||||
usage
|
||||
exit -2
|
||||
fi
|
||||
|
||||
# version/template selection
|
||||
if [ "$VERSION" == "21" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET21
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/21
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_BASE}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
if [ "$VERSION" == "19" ]; then
|
||||
. oraenv <<EOF!
|
||||
SET19
|
||||
EOF!
|
||||
export ORACLE_SID=${DB_NAME}PRD
|
||||
BACKUP_DB_NAME=ASTY
|
||||
BACKUP_DIR=/mnt/yavin4/tmp/_oracle_/orabackup/_keep_/Standalone/19
|
||||
echo "spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora'" > ${ORACLE_BASE}/dbs/init${ORACLE_SID}.ora
|
||||
fi
|
||||
|
||||
|
||||
if [ -z "${BACKUP_DIR}" ]
|
||||
then
|
||||
echo "No template found for this database version"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# admin directories creation
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/adump
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/spfile
|
||||
mkdir -p ${ORACLE_BASE}/admin/${ORACLE_SID}/divers
|
||||
|
||||
|
||||
# init and spfile creation
|
||||
cp ${BACKUP_DIR}/init${BACKUP_DB_NAME}PRD.ora ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
sed -i -r "s/${BACKUP_DB_NAME}/${DB_NAME}/" ${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora
|
||||
|
||||
echo ${ORACLE_SID}
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
create spfile='${ORACLE_BASE}/admin/${ORACLE_SID}/spfile/spfile${ORACLE_SID}.ora' from pfile='${ORACLE_BASE}/admin/${ORACLE_SID}/pfile/init${ORACLE_SID}.ora';
|
||||
startup nomount;
|
||||
EOF!
|
||||
|
||||
# duplicate from template
|
||||
rman auxiliary / <<EOF!
|
||||
run
|
||||
{
|
||||
allocate auxiliary channel aux01 device type disk;
|
||||
allocate auxiliary channel aux02 device type disk;
|
||||
allocate auxiliary channel aux03 device type disk;
|
||||
allocate auxiliary channel aux04 device type disk;
|
||||
allocate auxiliary channel aux05 device type disk;
|
||||
allocate auxiliary channel aux06 device type disk;
|
||||
allocate auxiliary channel aux07 device type disk;
|
||||
allocate auxiliary channel aux08 device type disk;
|
||||
allocate auxiliary channel aux09 device type disk;
|
||||
allocate auxiliary channel aux10 device type disk;
|
||||
duplicate target database to ${DB_NAME} backup location '${BACKUP_DIR}/backupset/';
|
||||
}
|
||||
EOF!
|
||||
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
shutdown immediate;
|
||||
startup;
|
||||
EOF!
|
||||
|
||||
# datapatch & recompile
|
||||
cd ${ORACLE_HOME}/OPatch
|
||||
./datapatch
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
@$ORACLE_HOME/rdbms/admin/utlrp
|
||||
-- recompile all in PDB$SEED
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read write instances=ALL;
|
||||
alter session set container=PDB\$SEED;
|
||||
alter session set "_ORACLE_SCRIPT"=true;
|
||||
@?/rdbms/admin/utlrp
|
||||
alter session set "_ORACLE_SCRIPT"=false;
|
||||
alter session set container=CDB\$ROOT;
|
||||
alter pluggable database PDB\$SEED close immediate instances=ALL;
|
||||
alter pluggable database PDB\$SEED open read only instances=ALL;
|
||||
EOF!
|
||||
|
||||
# NEWID
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
shutdown immediate;
|
||||
startup mount exclusive;
|
||||
EOF!
|
||||
|
||||
nid TARGET=/ LOGFILE=/tmp/nid.log
|
||||
|
||||
sqlplus /nolog <<EOF!
|
||||
connect / as sysdba
|
||||
startup mount exclusive;
|
||||
alter database open resetlogs;
|
||||
shutdown immediate;
|
||||
startup;
|
||||
EOF!
|
||||
2
bash/kvm_dump_guest_xml.sh
Normal file
2
bash/kvm_dump_guest_xml.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
virsh list --all --name | xargs -I{} echo "virsh dumpxml {} > /mnt/yavin4/tmp/_oracle_/tmp/{}.xml"
|
||||
|
||||
7
bash/oracle_path_swgalaxy.sh
Normal file
7
bash/oracle_path_swgalaxy.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
P1=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/tpt
|
||||
P2=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/idev
|
||||
P3=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/vg
|
||||
P4=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/vdh
|
||||
P5=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/Kevin_Meade
|
||||
P6=/mnt/yavin4/tmp/_oracle_/code_gitlab/oracle/my
|
||||
export ORACLE_PATH=${P1}:${P2}:${P3}:${P4}:${P5}:${P6}
|
||||
17
bash/quemu-mount.sh
Normal file
17
bash/quemu-mount.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# usage: qemu-mount {imagefile}
|
||||
# 1st argument: QEMU raw image file
|
||||
|
||||
if [ $# -ne 1 ] ; then
|
||||
echo 'usage: qemu-mount imagefile'
|
||||
echo 'Mounts a QEMU raw image file to /mnt/temp'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start=$( fdisk -l -o Device,Start ${1} | grep "^${1}1" | gawk '{print $2}' )
|
||||
sectors=$( fdisk -l ${1} | grep '^Units: sectors of' | gawk '{print $(NF-1)}' )
|
||||
offset=$(( $start * $sectors ))
|
||||
|
||||
[ -d /mnt/temp ] || mkdir /mnt/temp
|
||||
sudo mount -o loop,offset=$offset ${1} /mnt/temp
|
||||
|
||||
111
bash/vmclone.sh
Normal file
111
bash/vmclone.sh
Normal file
@@ -0,0 +1,111 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: vmclone -s|--source <SOURCE_VM> -t|--target <TARGET_VM> -o|--scriptonly"
|
||||
echo " o| --scriptonly, only clone script is generated, the clone command will not be executed"
|
||||
}
|
||||
|
||||
########
|
||||
# MAIN #
|
||||
########
|
||||
|
||||
typeset SOURCE_VM
|
||||
typeset TARGET_VM
|
||||
typeset SCRIPTONLY
|
||||
typeset CLONESCRIPT="/tmp/kvmclone.sh"
|
||||
typeset -i DISK_COUNT_SOURCE
|
||||
typeset -i I
|
||||
typeset RC
|
||||
typeset REPLACE
|
||||
|
||||
# parameter processing
|
||||
while [ "$1" != "" ]; do
|
||||
case $1 in
|
||||
-s | --source ) shift
|
||||
SOURCE_VM="$1"
|
||||
;;
|
||||
-t | --target ) shift
|
||||
TARGET_VM="$1"
|
||||
;;
|
||||
-o | --scriptonly ) SCRIPTONLY=true
|
||||
;;
|
||||
-r | --replace ) REPLACE=true
|
||||
;;
|
||||
-h | --help ) usage
|
||||
exit
|
||||
;;
|
||||
* ) usage
|
||||
exit 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
if [ -z "$SOURCE_VM" ] || [ -z "$TARGET_VM" ]; then
|
||||
usage
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if source VM exists
|
||||
I=$(virsh list --all | grep $SOURCE_VM | wc -l)
|
||||
if (( I == 0 )); then
|
||||
echo "Source VM ($SOURCE_VM) does not exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if source VM is shut off
|
||||
RC=$(virsh domstate $SOURCE_VM)
|
||||
if [ "$RC" != "shut off" ]; then
|
||||
echo "Source VM ($SOURCE_VM) is $RC, please shut it down first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check if target VM exists
|
||||
I=$(virsh list --all | grep $TARGET_VM | wc -l)
|
||||
if (( I > 0 )); then
|
||||
# -r|--replace option was used
|
||||
if [ "$REPLACE" == true ] ; then
|
||||
# destroy the VM and the underlayng storage
|
||||
echo "Shutdown VM $TARGET_VM"
|
||||
virsh destroy $TARGET_VM > /dev/null 2>&1
|
||||
echo "Remove VM $TARGET_VM"
|
||||
virsh undefine $TARGET_VM --remove-all-storage > /dev/null 2>&1
|
||||
else
|
||||
echo "Target VM ($TARGET_VM) already exists, use -r|--replace option to replace it"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# generate KVM clone shell
|
||||
rm -rf $CLONESCRIPT
|
||||
echo -e "#!/usr/bin/bash"'\n' >> $CLONESCRIPT
|
||||
chmod +x $CLONESCRIPT
|
||||
|
||||
echo "virt-clone \\" >> $CLONESCRIPT
|
||||
echo " --original $SOURCE_VM \\" >> $CLONESCRIPT
|
||||
echo " --name $TARGET_VM \\" >> $CLONESCRIPT
|
||||
|
||||
DISK_COUNT_SOURCE=$(virsh domblklist ${SOURCE_VM} --details | grep -v cdrom | grep "file" | wc -l)
|
||||
|
||||
I=0
|
||||
for DISK in $(virsh domblklist ${SOURCE_VM} --details | grep -v cdrom | grep "file" | awk -F " " '{ print $4}')
|
||||
do
|
||||
I=$((I+1))
|
||||
NEWDISK=${DISK/$SOURCE_VM/$TARGET_VM}
|
||||
if (( I < DISK_COUNT_SOURCE )); then
|
||||
echo " --file $NEWDISK \\" >> $CLONESCRIPT
|
||||
else
|
||||
echo " --file $NEWDISK" >> $CLONESCRIPT
|
||||
fi
|
||||
done
|
||||
|
||||
echo "KVM clone script [$SOURCE_VM -> $TARGET_VM] has been generated: $CLONESCRIPT"
|
||||
|
||||
if [ "$SCRIPTONLY" != true ] ; then
|
||||
# recreate VM storage directories
|
||||
cat $CLONESCRIPT | grep '\-\-file' | xargs -I{} echo {} | sed "s/--file//g" | sed 's/ //g' | xargs -I{} dirname {} | sort -u | xargs -I{} rm -rf {}
|
||||
cat $CLONESCRIPT | grep '\-\-file' | xargs -I{} echo {} | sed "s/--file//g" | sed 's/ //g' | xargs -I{} dirname {} | sort -u | xargs -I{} mkdir -p {}
|
||||
# Run generated KVM clone shell
|
||||
echo "Executing $CLONESCRIPT.."
|
||||
$CLONESCRIPT
|
||||
fi
|
||||
Reference in New Issue
Block a user