A narrow path between tall bamboo stalks in Kyoto, with warm light at the far end.

uc-local-apex-dev 26.5: better backups, utPLSQL, and more

uc-local-apex-dev 26.5 backs up objects that a Data Pump schema export misses, rebuilds your local database in one command, and adds utPLSQL installation and space management tools.

TL;DR: uc-local-apex-dev 26.5 ships with Oracle AI Database 26ai Free, version 23.26.4, and is mostly about backups. A schema export misses things you configured around your schemas, like grants and synonyms. The new backup captures those and tells you what needs manual recovery. This release also adds a one-command utPLSQL install and housekeeping to help keep Database Free under 12 GB.

Backups beyond the schema export

The backup scripts have always exported the three parts of an APEX project: the schema with Data Pump, the APEX workspace and applications, and the ORDS REST definitions. That covers most of your work. But a Data Pump schema export misses parts of the setup around your schema:

  • Custom profiles and tablespaces
  • Roles, system privileges, and grants on SYS objects like utl_http
  • Public synonyms and network ACL entries
  • Directories, and the files in them
  • Scheduler windows, job classes, Resource Manager plans, editions
  • VPD and Data Redaction policies, audit policies, application contexts
  • Assertions and schema privileges (grant ... on schema), both new in 26ai
  • Deep Data Security data roles, end users, and data grants

You usually notice this on the new machine, when the first package doesn’t compile because a grant is missing.

backup-all now starts with a new step, export-gaps. It reads the database and writes recovery SQL to ./backups/export/recovery. 00_pre.sql runs before the imports and recreates profiles, tablespaces, roles, directories, and discovered users. 10_post.sql runs afterward and restores grants, synonyms, and policies.

The old backup selected schemas from .env. Now export-gaps also finds unlisted schemas with objects or an APEX workspace. If you created a user by hand for a quick test, backup-all takes a full Data Pump schema export, including the table data. And export-gaps copies the files in custom directories, so the CSV behind your external table comes back as well.

At the end you get a short report. FXA and FXB are schemas I created for the backup and restore tests.

Schemas that are not in .env. The backup finds them in the database:
      FXA
      FXB

Counts of what the recovery files restore
      roles               : 3
      object grants       : 33
      public synonyms     : 3
      network entries     : 5
      directories         : 2
      scheduler windows   : 2
      resource plans      : 1
      data roles          : 0
      end users           : 0

Things that no backup can hold are listed in unrecoverable.txt.

What it can’t do

Some things can’t be backed up. Even sys can’t read the password of a credential or a database link. Check unrecoverable.txt for the items in your database that need manual work.

What the backup missesWhat to do
Database link passwordsRecreate the links with their passwords.
APEX web credential secretsIn Workspace Utilities → Web Credentials, enter the secret if the credential came back with an application. If it was absent from the application exports, recreate it with its original static ID and enter the secret.
Passwords for DBMS_CREDENTIAL credentialsThe restore sets the placeholder password to CHANGE_ME. Replace it with the real password.
Objects that exist only in an edition (create edition) other than the defaultSave their definitions before the rebuild. Recreate the objects in their original editions after the restore.
SQL plan baselinesTo keep them, capture them with DBMS_SPM.PACK_STGTAB_BASELINE before the rebuild.
SQL Firewall allow listsCapture and generate the allow lists again with DBMS_SQL_FIREWALL.
Unsent APEX emailQueue the emails again after the restore.
Deep Data Security end-user passwordsSet new passwords and unlock the accounts. The restore creates them with random passwords and locks them.

Select AI profiles go into ai_profiles.sql. import-all skips that file. Recreate or update the profile’s credential, then run the profile’s block yourself as its owner.

Checking the restore

On the import side, import-all runs the recovery files around the Data Pump imports and restores the directory files. Afterwards it compares every object of every schema with a manifest taken at backup time, including the SQL domain of every column:

== Phase 0: 00_pre.sql (profiles, tablespaces, roles, directories, scheduler windows, discovered users)
  00_pre.sql: 0 statements failed. See ./backups/import/logs/00_pre.log
== Phase 0: directory paths and files
  restored the files of directory FX_DIR2 (/opt/oracle/oradata/fx_dir2)
  restored the files of directory FX_DIR (/opt/oracle/oradata/fx_dir)
== Phase 1: create users
== Phase 2: DataPump with 1 parallel job(s)
✓ data imported for FXA
✓ data imported for FXB
✓ data imported for RESTORE_TEST
== Phase: apex
== Phase: ords
== Phase 5: 10_post.sql (grants, synonyms, network entries, contexts, policies)
  10_post.sql: 2 statements failed. See ./backups/import/logs/10_post.log
== Check: objects against the backup
  WARNING: these objects did not come back:
    FXA UNDEFINED FX_ASSERT
    FXA UNDEFINED FX_ASSERT2

That output is from a real test run before the 26.5 fix for those two assertions. More on why below. A restore that silently loses something is worse than one that fails loudly.

rebuild: a fresh database in one command

With a backup you can trust, you can throw the database away. That’s what rebuild does:

./local-26ai.sh rebuild

It runs backup-all, shows you the items that need manual recovery, and asks you to type the volume name. Then it deletes the database volume, installs a fresh database with the image in docker-compose.yml, and runs import-all. It reinstalls DBMS_CLOUD and utPLSQL if they were present. If the old database had more vector memory (RAM for vector indexes), the restore raises the new allocation to match.

This is also the clean way to upgrade to a new database version. A new release update image can use your old datafiles and keeps the old data dictionary. New features that need new dictionary objects won’t work, and the image swap can break the in-database JVM. rebuild gives you a fresh database with the new dictionary. It imports your backup, and unrecoverable.txt lists the exceptions that need your attention.

I recommend keeping your own scripts for what the backup can’t recover, for example a script that calls apex_credential.create_credential. But store it safely, like in your password manager.

Data Pump gaps I found on the way

Building this meant testing a lot of restores. Data Pump mishandled several features without reporting an export error. I found these problems on import:

  • Deep Data Security grants come back broken. Imported grants show up in DBA_DATA_GRANTS, but end users get ORA-00942 when they try to use them. For related-table grants (WHEN ... GRANTED ON), Data Pump generates an invalid PL/SQL block. That block fails on import, and the other grants in it don’t get applied. The restore skips the internal grant objects and recreates supported grants with CREATE DATA GRANT. Recreate related-table grants yourself. (If you haven’t looked at DDS yet, here’s my blog post about it.)
  • SQL domains land on the wrong column. If an invisible virtual column comes before columns with SQL domains, Data Pump can bind each domain to the following column. A domain meant for column B lands on column C. If the data types match, the wrong domain sticks without an error. The backup lists affected tables, and the post-import check flags incorrect domain links.
  • Domains with TIMESTAMP. A domain as timestamp is exported as TIMESTAMP () and fails on import with ORA-30088. The restore creates these domains with corrected DDL first.
  • Assertion helper tables on 23.26.4. Data Pump exports an assertion’s internal helper tables as normal tables. The imported copies block CREATE ASSERTION with ORA-08730. The 26.5 fix drops those leftover tables before it recreates the assertions.

utPLSQL in one command

utPLSQL is the awesome unit testing framework for PL/SQL by Jacek Gebal. I always recommend writing unit tests for your projects. Now it takes one command to install the framework:

./local-26ai.sh install-utplsql

The command downloads the latest release from GitHub and installs the framework in its own UTPLSQL schema and tablespace. The public synonyms let you run tests straight from your application schema:

select * from table(ut.run());

Run the same command again to upgrade. utPLSQL’s own docs say an upgrade means removing the old version and installing the new one, so the command drops and recreates the UTPLSQL schema (don’t keep your own objects there). And since rebuild knows whether your old database had utPLSQL, it comes back automatically. There’s a new utPLSQL page in the docs.

Housekeeping

Oracle Database Free limits a PDB to 12 GB of datafiles. You don’t want to hit that limit. Once operations start failing for lack of space, freeing space gets harder.

I recommend running ./local-26ai.sh shrink-space regularly. This release makes managing space easier.

Purge jobs. Two new scheduler jobs keep 7 days of data:

  • UC_APEX_DEBUG_PURGE runs every night and removes APEX debug messages older than 7 days for every application. On one of my databases the debug tables alone held 455 MB.
  • UC_LOGGER_PURGE deletes Logger rows older than 7 days in every schema that has a LOGGER_LOGS table, keeps permanent entries, and shrinks the table afterwards.

New installs get both jobs. On an existing install, run create-purge-jobs once.

shrink-space rebuilds bloated tables. A delete doesn’t lower a table’s high-water mark. A table that once held millions of rows keeps its full segment, and shrinking the tablespace can’t get past it. shrink-space now looks at every table with a segment of 50 MB or more, estimates the size of its live rows, and if that’s less than half the segment, it lists the table and offers to rebuild it with alter table ... move online plus online index rebuilds.

A new report in used-space tells you where the space went. For every tablespace with 1 GB or more of used space, it now lists the 10 largest segments (LOBs and indexes show their table), and it shows which APEX applications carry the most file content.

stop guards the limit. I recommend ./local-26ai.sh stop to shut down. If the space check reports CRITICAL (11 GB or more by default), it runs shrink-space --auto while the PDB is still open. If space is still CRITICAL afterward, stop leaves the database running and exits with code 11. That’s your chance to free more space. If the PDB exceeds 12 GB, the next open fails with ORA-12954, so you can’t run the cleanup from inside it.

Upgrading to 26.5

26.5 moves to Oracle AI Database 26ai Free, version 23.26.4, and ORDS 26.3.1. Follow the 26.5 migration guide. It sends you to Upgrade the Database to choose one of these two paths.

Image swap (a few minutes). Stop, check out the 26-5 branch, then start. The new image uses your existing datafiles. Then run fix-jvm, a new command that tests the in-database JVM and reloads it if the image swap broke it. The data dictionary stays at the old version.

Export and import (more than 30 minutes ). Check out 26-5 while the old database keeps running, pull the new image, and run rebuild. You end up with a fresh 23.26.4 database and your imported data, subject to the gaps in unrecoverable.txt.

As always, the project is open source on GitHub. If something doesn’t come back after a restore, please open an issue.

Homepage •All Blogposts

AI disclaimer: I spend hours writing my blog posts by hand, adding my own thoughts and experiences to them. In my view, purely AI-generated content lacks that human depth and isn't worth publishing. I only use AI for research and editing assistance.