How to restore a deleted Plan in Bamboo
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This article provides some options on how to restore a deleted Plan in Bamboo.
When a plan is deleted in Bamboo, it gets marked for deletion along with any dependent objects (build results, unlinked artifacts, comments, favourites, etc). The deletion/cleanup process usually happens within 15 minutes after the delete action was issued in the UI.
Unfortunately, Bamboo has no undo functionality for delete actions and the only way to granularly recover a point in the past would be by checking an old snapshot of the database and extracting the required information and using it to configure the Plan again.
Solution
Recover from SQL
To recover the structure of a deleted plan from an old Bamboo database, please follow the steps below:
- Restore your Bamboo database to a point in time where your deleted Plan was still available
- Run the following SQL commands to find the build definition for that plan:
Identify your missing plan(CHAIN) and take note of its "build_id"
Show all PlansSELECT * FROM build WHERE build_type = 'CHAIN';
Having the build_id of your missing plan, run the next query to find all the related stages and their Jobs:
Use this to recreate the StagesSELECT * FROM chain_stage WHERE build_id = '<your_build_id>';
Use this to create the Jobs skeletonSELECT * FROM build WHERE stage_id IN (SELECT stage_id FROM chain_stage WHERE build_id = '<your_build_id>')
List each Job's content and recreate them on your running Instance:
Use this to create each Job contentSELECT xml_definition_data FROM build_definition WHERE build_id IN (SELECT build_id FROM build WHERE stage_id IN (SELECT stage_id FROM chain_stage WHERE build_id = '<your_build_id>'));
All the build definition data are presented in XML format, please make sure to move the SQL output to an XML editor for better visualisation.
Restore from Backup
There is also an alternative way that would involve restoring your Bamboo and Database instances in a temporary location and then using Bamboo Specs to export the Plan configuration and use it to Create the plan with Bamboo Java Specs in your current/active/ongoing Bamboo instance. Using Specs is optional as you can also opt to reconfigure your missing Plan by shadowing the configuration manually from the restored instance.
If your Bamboo environment has a programmatic exported backup, you can crawl into the exported files to find the deleted plan structure and recover your configuration without any excessive work. The exported backup format was created to be imported as a whole and not used as an individual recovery method. Be mindful that the required dependencies related to a specific plan may not be easily located using this strategy as usually requires a lot of research within several XML files.