-
Notifications
You must be signed in to change notification settings - Fork 0
/
20_create_new_level_0_backup.sh
145 lines (122 loc) · 3.84 KB
/
20_create_new_level_0_backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/sh +vx
#
# This script is part of performing Oracle Incremental Merge and Live Mount with Data Domain snapshot with Data Domain BoostFS
#
# Script: 20_create_new_level_0_backup.sh
#
# Author: Trichy Premkumar, prem@acslink.net.au
#
# Disclaimer: Scripts have been developed for testing Oracle incremental merge with Data Domain snapshot
# No support or warranty is included
#
# #IWork4DELL
#
# Pre-requisites:
#
# - BoostFS setup and mounted. 10_mount_boostfs.sh has been executed and BoostFS has been setup
#
# Function:
#
# - Script to create a new Level 0 backup. It will delete old Level 0 backup, on Data Domain, it does not affect previous backups using this copy
#
#
# Read environment varibles
#
if [ -z ${SCRIPTS_DIR} ]
then
echo " "
echo "Location of scripts is not know - please set environment variable SCRIPTS_DIR to the location of scripts"
echo " "
exit 1
else
if [ -f ${SCRIPTS_DIR}/00_set_environment.inc ]
then
. ${SCRIPTS_DIR}/00_set_environment.inc
else
echo " "
echo "Environment variable script cannot be located.. exiting."
echo " "
exit 1
fi
fi
#
#
if [ -d ${L0_BACKUP_LOCATION} ];
then
if [ `ls -l ${L0_BACKUP_LOCATION}/* 2>/dev/null | wc -l ` = 0 ];
then
echo " "
echo "Dir ${L0_BACKUP_LOCATION} is empty"
echo " "
else
echo " "
echo "List of Level 0 files for deletion in directory: ${L0_BACKUP_LOCATION}/*"
echo " "
ls ${L0_BACKUP_LOCATION}/*
echo " "
echo "About to clean old Level 0 backup for a new Level 0"
echo " "
echo "About to execute rm -f ${L0_BACKUP_LOCATION}/*"
echo " "
echo "Press Control+C to abort, return to continue"
echo " "
read x
rm -f ${L0_BACKUP_LOCATION}/*
fi
else
echo "Unable to locate Backup Location for Level 0.. Environment not setup.. exiting.."
exit 1
fi
echo " "
echo "Proceeding to create Level 0 backup at ${L0_BACKUP_LOCATION}"
echo " "
rman target / << LEVEL0-BACKUP
SET ECHO ON
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE ENCRYPTION FOR DATABASE OFF;
CONFIGURE COMPRESSION ALGORITHM 'BASIC';
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM ${RMAN_PARALLELISM};
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF ${RMAN_RETENTION_DAYS} DAYS;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '${CONTROL_BACKUP_LOCATION}/%d_%F.ctl';
run {
sql 'ALTER SYSTEM SWITCH LOGFILE';
BACKUP AS COPY INCREMENTAL LEVEL 0 TAG "${INCR_MERGE_TAG}" DATABASE format '${L0_BACKUP_LOCATION}/%d_TS_%N_FNO_%f.${DB_FILE_EXTN}';
sql 'ALTER SYSTEM ARCHIVE LOG CURRENT';
backup archivelog all format '${ARCH_BACKUP_LOCATION}/%d_Archive_%u.${ARCH_FILE_EXTN}' not backed up 1 times;
}
LEVEL0-BACKUP
echo " "
echo "About to create Snapshot of L0 backup : ${L0_BACKUP_LOCATION} "
echo " "
echo "Snapshot dir = ${BOOSTFS_MOUNT}/${DD_SNAPSHOT_DIR}"
echo " "
echo "Press any key to start "
echo " "
read x
ssh ${DD_SNAPSHOT_USER}@${DATA_DOMAIN} filesys fastcopy source /data/col1/${MTREE}/${DD_L0_BACKUP_LOCATION} destination /data/col1/${MTREE}/${DD_SNAPSHOT_DIR}
echo " "
#
# Wait until snapshot directory is ready
#
ls -l ${BOOSTFS_MOUNT}/${DD_SNAPSHOT_DIR}/* > /dev/null 2>&1
rs=$?
while [ $rs -ne 0 ];
do
echo "Waiting for snapshot directory ${BOOSTFS_MOUNT}/${DD_SNAPSHOT_DIR} to be ready.. "
sleep 2
ls -l ${BOOSTFS_MOUNT}/${DD_SNAPSHOT_DIR}/* > /dev/null 2>&1
rs=$?
done
#
# Generate a list of files to Catalog and catalog the snapshot within Oracle database for recovery
#
#
echo " " > /tmp/${SNAPSHOT_TAG}.rman
for file in `ls ${BOOSTFS_MOUNT}/${DD_SNAPSHOT_DIR}/*`
do
echo "catalog datafilecopy '${file}' TAG='${SNAPSHOT_TAG}' ; " >> /tmp/${SNAPSHOT_TAG}.rman
done
echo "exit" >> /tmp/${SNAPSHOT_TAG}.rman
rman target / @/tmp/${SNAPSHOT_TAG}.rman