Recovering accidentally deleted user macro


I accidentally deleted a user macro - instead of clicking on Edit, I clicked on Delete :(

Is there a way to recover the deleted user macro? I have daily backups of the whole installation of Confluence.

Thank you!

1 answer

1 accepted

2 votes
Accepted answer

Ok, I finally found the solution so here it is.

This requires that you have a backup of the confluence database from before deleting the macro. In my case, the database is in postgreSQL so I will use that as an example.

  1. Obtain the backup file: confluence_backup.sql
  2. On a local postgreSQL server create a new empty database called confluence
  3. Import the backup file to the newly created database as follows:
  4. Right click on the empty confluence database and click Restore...
  5. Select the backup file
  6. Press Restore
  7. Browse in the tree to confluence > Schemas > public > Tables > bandana
  8. Right click on the table bandana and select View Data > View Filtered Rows
  9. Enter the following query: bandanakey = 'atlassian.confluence.user.macros'
  10. Click on the Value cell (visible text should be <map>), select all the text and copy to a text editor.

Now you have multiple options. You could either look for the lost macro in the file, select the whole of it (everything between <entry> and </entry> inclusive the two tags) and copy it to your active confluence database (you can connect to it just like you did for the local one) or you could copy the whole content and replace it (if you did not change anything else, for example).

After that save the database and restart confluence. The macro will now be there again!

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Feb 06, 2019 in Confluence

Try out the new editing experience

Hi team, I’m Avinoam, a product manager on Confluence Cloud, and today I’m really excited to let the Community know that all customers can now try out the new editing experience and see some of the ...

1,465 views 114 8
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you