12 Days of #Cloud: Day 6
When I created the #DBaaS instance, did not create a backup policy. I chose the backups as “None”. Now that some work has been done on the database, would like to create an adhoc backup as well as want to schedule regular local disk backups.
On-demand backup can be performed by running script “/var/opt/oracle/bkup_api/bkup_api bkup_start” as the root user.
[opc@CLDB4ACED ~]$ sudo -s [root@CLDB4ACED opc]# [root@CLDB4ACED opc]# /var/opt/oracle/bkup_api/bkup_api bkup_start DBaaS Backup API V1.5 @2015 Multi-Oracle home -> Action : bkup_start -> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log API INFO : Backups are not configured on this DB Instance. Nothing to do. * * RETURN CODE:0 ################################################## [root@CLDB4ACED opc]#
Oops, no backup configured! So, for the first time, we need to configure backup before we can perform a backup.
Reference: Oracle Documentation
Backup configuration is saved in file /var/opt/oracle/ocde/assistants/bkup/bkup.cfg. Let’s edit the file and add required parameters.
[opc@CLDB4ACED ~]$ sudo -s [root@CLDB4ACED opc]# [root@CLDB4ACED opc]# cd /var/opt/oracle/ocde/assistants/bkup/ [root@CLDB4ACED bkup]# ls *cfg bkup.cfg [root@CLDB4ACED bkup]# cat bkup.cfg # The bkup.cfg file will hold all the config info for BKUP [root@CLDB4ACED bkup]# cp -p bkup.cfg bkup.cfg.1 [root@CLDB4ACED bkup]# vi bkup.cfg [root@CLDB4ACED bkup]# cat bkup.cfg # The bkup.cfg file will hold all the config info for BKUP bkup_cfg_files=yes bkup_disk=yes bkup_disk_recovery_window=2 bkup_oss=no bkup_oss_url=oss_url bkup_oss_user=username bkup_oss_passwd=password bkup_oss_recovery_window=30 [root@CLDB4ACED bkup]# [root@CLDB4ACED bkup]# chown root bkup.cfg [root@CLDB4ACED bkup]# chmod 0600 bkup.cfg [root@CLDB4ACED bkup]# ./bkup -cfg bkup.cfg Starting BKUP Logfile is /var/opt/oracle/log/bkup/bkup_2016-12-06_17:01:47.log Config file is bkup.cfg dbname: CDDB01 Dataguard configuration Enabled: 0 Mode: PRIMARY Looking for previous configuration: Directory : /home/oracle/bkup/CDDB01 -> obkup -> dbcfg.spec -> log -> Found: 3 files -> Moving previous configutarion to /home/oracle/bkup/CDDB01_20161206170154 No initial bkup of PFILE needed. Configuring Backup to disk Common RMAN Config Instantiating obkup Instantiating dbcfg.spec Configuring backup of Config File Updating Control File Record Keep Time Enabling block change tracking Updating RMAN defaults Adding entry to crontab INFO: Archivelog management enabled. Warning: there are already 1 entries for crontab -> 0,30 * * * * root /home/oracle/bkup/CDDB01/obkup -dbname=CDDB01 -archivelog Accessing to your Database ID .. The DBaaS instance database id is: 4135691349 Deleting unencrypted autobackups. #### Completed Execution. [root@CLDB4ACED bkup]#
BKUP_DISK is for local disk backup, and enabled local backup by setting this parameter to YES. Local disk backups are written to the Flash Recovery Area, which is /u03/app/oracle/fast_recovery_area directory. The parameter BKUP_OSS is to write backups to Oracle Cloud Storage.
The bkup script, backup assistant, created few cron jobs to do the backup periodically.
[root@CLDB4ACED etc]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="" HOME=/ # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # | | | | | # * * * * * user-name command to be executed 0,30 * * * * root /home/oracle/bkup/CDDB01/obkup -dbname=CDDB01 -archivelog 15 03 * * 6 oracle /var/opt/oracle/cleandb/cleandblogs.pl 54 2 * * * root /var/opt/oracle/bkup_api/bkup_api bkup_start --dbname=CDDB01 [root@CLDB4ACED etc]#
Let’s kick off the backup again.
[root@CLDB4ACED etc]# /var/opt/oracle/bkup_api/bkup_api bkup_start --dbname=CDDB01 DBaaS Backup API V1.5 @2015 Multi-Oracle home -> Action : bkup_start -> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log ** process started with PID: 23297 ** see log file for monitor progress ------------------------------------- [root@CLDB4ACED etc]# [root@CLDB4ACED etc]# cat /var/opt/oracle/bkup_api/log/bkup_api.log ... ... ... Tue, 06 Dec 2016 17:17:25 DBaaS Backup API V1.5 @2015 Multi-Oracle home Tue, 06 Dec 2016 17:17:25 -> Action : bkup_start Tue, 06 Dec 2016 17:17:25 -> logfile: /var/opt/oracle/bkup_api/log/bkup_api.log Tue, 06 Dec 2016 17:17:25 ** process started with PID: 23297 Tue, 06 Dec 2016 17:17:25 db35376e-bbd7-11e6-9159-c6b07b253285 -> Starting execution of backup log in background Tue, 06 Dec 2016 17:17:25 ** see log file for monitor progress Tue, 06 Dec 2016 17:17:25 ------------------------------------- Tue, 06 Dec 2016 17:17:25 db35376e-bbd7-11e6-9159-c6b07b253285 STARTING BACKUP REQUEST Tue, 06 Dec 2016 17:17:25 Creating Backup Api registry datatabase Tue, 06 Dec 2016 17:17:25 UUID db35376e-bbd7-11e6-9159-c6b07b253285 written with PID 23297 Tue, 06 Dec 2016 17:17:33 db35376e-bbd7-11e6-9159-c6b07b253285 Checking if CDDB01 resource is available Tue, 06 Dec 2016 17:17:33 db35376e-bbd7-11e6-9159-c6b07b253285 registering request into the database Tue, 06 Dec 2016 17:17:37 db35376e-bbd7-11e6-9159-c6b07b253285 current backups 0 Tue, 06 Dec 2016 17:17:37 db35376e-bbd7-11e6-9159-c6b07b253285 command /home/oracle/bkup/CDDB01/obkup -dbname=CDDB01 Tue, 06 Dec 2016 17:19:54 db35376e-bbd7-11e6-9159-c6b07b253285 The backup process failed
Backup failed! This time, it was due to insufficient local storage to hold the backup. Since I chose no backup option, Oracle Cloud Service did not allocate storage to perform backups to /u03 file system. The database was created in ARCHIVELOG mode, and the Cloud Service setup a cron job to remove the archivelog files hourly.
It took a while to figure out how to add storage to /u03 file system. More storage is added to the standard file systems by using the “Scale up or down Resources” menu item.
Added 50G to “Backup Storage Volume”, which is /u03. 6G volume is now 56G.
Adding disk space alone is not sufficient, need to increase the Fast Recovery Area as well.
Though backup is scheduled to run periodically using the cronjobs, lets kick off a backup to verify if the added storage in /u03 resolved the backup issue.
Voila, successful backup!
DBaaS monitor console also shows the status.
The /home/oracle/bkup/CDDB01/obkup cron job performs operating system file backups. The file backups are based on two configuration files, and their contents are:
[root@CLDB4ACED CDDB01]# pwd /home/oracle/bkup/CDDB01 [root@CLDB4ACED CDDB01]# cat dbcfg.spec ### Oracle_Home configuration files. # # Doc Spec dbcfg.spec # DB id dbid # # Directories /u01/app/oracle/product/12.2.0/dbhome_1/admin/CDDB01/xdb_wallet /u01/app/oracle/admin/CDDB01/xdb_wallet /u01/app/oracle/admin/CDDB01/db_wallet /u01/app/oracle/admin/CDDB01/opc_wallet # Note: tde_wallet must be backed up in a different location than DATA bkup. /u01/app/oracle/admin/CDDB01/tde_wallet /u01/app/oracle/admin/CDDB01/cat_wallet #/u01/app/oraInventory # # Single files /u01/app/oracle/admin/CDDB01/opcCDDB01.ora /u01/app/oracle/product/12.2.0/dbhome_1/dbs/orapwCDDB01 /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/sqlnet.ora /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/lib/env_rdbms.mk /u01/app/oracle/product/12.2.0/dbhome_1/rdbms/lib/ins_rdbms.mk # # Creg /var/opt/oracle/creg/CDDB01.ini # [root@CLDB4ACED CDDB01]# [root@CLDB4ACED CDDB01]# cat oscfg.spec ## OS Configuration Files # # Doc Spec oscfg.spec # # Directories /etc/rc.d /home/oracle/bkup # # Single files /home/oracle/.bashrc /etc/crontab /etc/sysctl.conf /etc/passwd /etc/group /etc/oraInst.loc /etc/oratab /etc/fstab [root@CLDB4ACED CDDB01]#
As you can see, all important files from the Operating System are backed up. If you have directories to be backed up, add to the dbcfg.spec file.
Enabling and performing cloud backups is also using similar steps. Update these parameters accordingly in the bkup.cfg file.
bkup_oss=yes bkup_oss_url=oss_url bkup_oss_user=username bkup_oss_passwd=password bkup_oss_recovery_window=30