DEV Community

Abdulrawof Totakhil
Abdulrawof Totakhil

Posted on Edited on

Automating Oracle Database Recycle Bin Maintenance: A Practical DBA Approach

Automating Database Maintenance and Email Reporting

Introduction

As well as ensuring the correct functioning, security and performance of databases, DBAs will often implement automation to further improve their processes.

Within an enterprise, there are many processes that can be undertaken, which are often carried out in a similar manner and so can take up considerable amounts of time. There is also an element of risk involved with undertaking these processes manually.

One such process is the management of an Oracle Database Recycle Bin.

I have been investigating how this can be automated using Linux shell scripting, along with job scheduling and automated email reporting as part of the continual enhancement of database maintenance.

  1. The Oracle Database Recycle Bin

The Oracle Database Recycle Bin stores information relating to tables and objects that have been dropped. This then means that they can subsequently be restored via Flashback Drop.

Rather than automatically deleting suitable dropped objects, Oracle stores them in a Recycle Bin until they are manually deleted or Oracle recycles the space that they use.

Advantages of this process are that it:

Prevents unintentional table deletion.

Allows suitable dropped tables to be restored.

Minimises the need for data to be restored from backups.

Improves adaptability.

Despite being stored, objects still utilise database space and this will be recycled where possible.

  1. Importance of Recycle Bin Maintenance

Within an enterprise database environment, objects may be both created and dropped as part of, for example, application deployment, development, testing and general database use. Consequently, the contents of the Recycle Bin can build up.

Periodic examination and subsequent management facilitates:

Release of database space used by stored objects.

Increased awareness of database space usage.

Compliance with business space management policy.

Implementation of a common database maintenance procedure.

Decreased manual input.

However, database objects must be deleted in accordance with a defined business space management policy – it is not sufficient to indiscriminately delete suitable dropped objects.

  1. Manual Database Maintenance

Traditionally, a DBA manually logs onto a database, investigates the contents of its Recycle Bin and applies suitable maintenance. They can then confirm the maintenance was successful and produce a report.

Whilst this is effective, there are several issues that can arise:

Availability of the DBA to undertake maintenance.

Failure to carry out maintenance at the intended times.

High levels of manual input.

Disparity in reports.

Human error.

Lack of centralised maintenance records.

Automation can alleviate these issues and enable a common, repeatable method of carrying out maintenance.

  1. Manual to Automated Transition

The key aim of the automation is to convert manual database maintenance into a managed, timed and monitored process.

Four elements are utilised in the automation:

Technology

Task

Oracle Database

Database maintenance and investigation

Linux Shell Scripting

Automation and control

Linux Cron

Job scheduling

Email Notification

Reporting and monitoring

These work together to facilitate a formalised maintenance process, without the need for continual manual involvement.

  1. Automation Process

The automated maintenance process comprises:

Commencing a job.

Setting up the relevant Oracle environment.

Confirming database availability and identifying its identity.

Investigating the Recycle Bin.

Carrying out suitable maintenance.

Reviewing the contents of the Recycle Bin.

Producing a report of the maintenance process.

Sending an automated email.

Therefore, as well as applying database maintenance, the automation includes investigation, monitoring and reporting facilities.

  1. Job Scheduling

As months can differ in terms of the number of days that they contain (30, 31 or 28/29 for February), it is important to recognise the last day of each calendar month. The maintenance can then be initiated on this day.

Benefits of doing so are that:

Database maintenance can be consistently applied each month.

There is decreased reliance on manual prompting for maintenance.

Job timing can be accurately predicted.

Better planning for maintenance can occur.

Uniformity is further enhanced.

The timing of the database maintenance should conform to both defined allowable periods and business needs.

  1. Pre- and Post-Maintenance Investigation

Investigation is a fundamental aspect of good quality automated database processes.

Prior to undertaking maintenance, the current volume of items within the database Recycle Bin is investigated. Following completion of the maintenance, the number of items remaining is then analysed and a report produced.

This assists DBAs to:

Recognise the original volume of Recycle Bin items.

Ascertain the post-maintenance volume of Recycle Bin items.

Determine whether or not the maintenance was successfully completed.

Identify if further investigation is necessary.

It is therefore important that tangible, analysable information is provided as a result of each instance of database maintenance.

  1. Automated Email Notification

Whilst automation can be implemented, good quality monitoring is also important.

Automated email notification can inform DBAs of:

Information regarding the maintenance.

Date and time of maintenance.

Database environment information.

Pre- and post-maintenance Recycle Bin contents.

Status of the maintenance.

Any relevant error information.

Consequently, DBAs can analyse the outcome of automated database maintenance, without needing to manually log onto database servers after each job is run.

Furthermore, automated email notification promotes both monitoring and record keeping.

  1. Error Management and Process Reliability

When developing an automated database process, it is important to manage situations where the process does not function as intended.

Such situations may involve:

Database inaccessibility.

Login failure.

Incorrect permissions.

Improper database environment.

Database maintenance issues.

Email dispatch problems.

Job scheduling issues.

The automation should recognise these and effectively communicate this information.

Even if a job has been successfully scheduled, this does not automatically indicate that the associated database maintenance was successfully undertaken. Both job and database outcomes should therefore be separately analysed.

  1. Security and Business Governance

Automated database processes must comply with relevant security and business governance rules.

Key areas to consider are:

Permissions for process execution.

Controlled access to automation components.

Appropriate job scheduling.

Database identity confirmation.

Secure reporting and record keeping.

Change management.

Business space management policy.

Confidential infrastructure information management.

As mentioned above, once items have been deleted from the Recycle Bin they can no longer be recovered by way of Flashback Drop. Hence, prior to allowing automated deletion to occur, it is important to evaluate who is permitted to undertake maintenance and the business’ recovery needs. Rather than circumventing business controls, automation should support them.

  1. Delivery and Testing

The automated database maintenance for the Recycle Bin was developed and tested within a non-production environment.

Delivery entailed:

Automation of database maintenance.

Pre- and post-maintenance investigation.

Production of maintenance status information.

Automated email notification.

Following appropriate technical evaluation and production sign-off, the next stage involves placing the automated maintenance on a monthly job schedule for controlled running.

It is crucial that non-production testing takes place prior to implementing automated database maintenance within production settings.

  1. Benefits

Manual

Automated

Manual execution.

Automated execution.

Manual investigation.

Automated investigation.

Manual reporting.

Automated email reporting.

DBA reliant.

Less reliance on DBAs.

Possibly variable timing of maintenance.

Standardised timing of maintenance.

Manual input.

Enhanced efficiency.

Manual logging of maintenance.

Formalised logging of maintenance.

Although automation does not remove a DBA’s role, it does allow them to concentrate more on higher level areas such as performance, security and infrastructure enhancement, as well as business governance.

  1. Implementing Automation within Critical Environments

Within critical database environments – such as those operating within the financial sector – it is vital that processes are reliable.

Even basic processes should be subject to suitable technical and business controls.

Before introducing automated database processes into production, DBAs should:

Test within a non-production environment.

Undergo technical evaluation.

Gain change sign-off.

Evaluate business impacts.

Develop recovery strategies.

Implement monitoring and notification.

Conduct post-implementation investigation.

Good quality automation must successfully address efficiency requirements, alongside security, reliability and business continuity needs.

  1. Further Enhancements

In addition to the above, the automated maintenance approach can also be applied to other Oracle Database processes. For example:

Investigation of tablespace space utilisation.

Validation of RMAN backups.

Analysis of non-valid database objects.

Investigation of database health.

Investigation of audit space utilisation.

Monitoring of Data Guard synchronisation.

Investigation of Oracle RAC service status.

Analysis of ASM space utilisation.

Database security reporting.

By progressively automating routine processes, businesses can further develop a standardised, forward-thinking database management function.

Conclusion

The automated management of an Oracle Database Recycle Bin is a good illustration of how an automated solution can enhance typical database administration processes.

Utilising Oracle Database, along with Linux job scheduling, investigation and email notification facilities, enables a formalised automated maintenance solution to be implemented.

Whilst automation is often undertaken to decrease manual input, the key benefit is that it can help to improve process standardisation, reliability and transparency. Appropriate security and business governance must however continue to be in place.

Alongside ensuring that databases function effectively, good quality database management also involves continually seeking to further enhance database processes.

Further Oracle Information

Oracle Database Administrator’s Guide

https://docs.oracle.com/en/database/oracle/oracle-database/19/admin/

Oracle Database SQL Language Reference

https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/

Oracle Database Backup and Recovery User’s Guide

https://docs.oracle.com/en/database/oracle/oracle-database/19/bradv/

Author

Abdulrawof Totakhil

Database Administrator – Oracle Database, Linux, Automation, High Availability & Disaster Recovery

With an interest in enterprise database, business process excellence, database security, infrastructure evolution and automation.

Connect and Share Knowledge

LinkedIn: https://www.linkedin.com/in/abdulrawof-totakhil

Together, let us learn, share and develop.

Top comments (0)