Audience
OCI administrators, DevOps engineers, cloud engineers, platform teams, SREs, and developers who manage Oracle Cloud Infrastructure Functions and need a way to recover or archive the code packaged in deployed function images.
Introduction
OCI Functions makes it easy to deploy serverless workloads, but there are situations where you may need to retrieve the code currently deployed in your tenancy.
Use Case:
- Back up deployed functions before a migration.
- Recover code when the original repository is unavailable.
- Audit what is actually deployed in production.
- Archive functions before decommissioning an application.
- Compare deployed artifacts with source-control versions.
OCI Functions does not provide the original source repository directly from the Function resource. A deployed OCI Function references a container image, typically stored in OCI Container Registry, or OCIR.
That means the recovery process is essentially looks like below:

Solution Overview
The solution described below automates this process across all accessible Functions applications in a tenancy.
By combining OCI Resource Search, the OCI CLI, Docker, and Python, it is possible to automate the entire process across a tenancy:

Refer to the GitHub here to get the python script for this solution.
The Python script performs the following tasks:
- Searches the tenancy for OCI Functions applications.
- Finds all functions inside each application.
- Retrieves the container image configured for each function.
- Logs in to the corresponding OCIR registry.
- Pulls the deployed image.
- Creates a temporary Docker container.
- Copies only the contents of the /function directory.
- Creates a tar file named after the function.
- Stores the tar file under a directory named after the application.
- Removes the temporary container.
- Removes the downloaded image to reclaim local disk space.
Conclusion
OCI Functions are ultimately deployed as container images, which provides a useful recovery path when the packaged code needs to be retrieved.
The resulting backups are compact, easy to organize, and represent the code and files that were actually packaged into each deployed function image.
For teams managing large OCI Functions environments, this approach can also serve as the foundation for a broader deployment-audit, migration, or disaster-recovery workflow.
