Bulk delete / purge Confluence page history / versions
Asked by Guenter Huber:

So, the **question** is:  
When I delete page versions from the history, do they really / automatically get purged or do i need to do something else? (Some DB SQL command maybe?)

For others desperate / left alone by Atlassian out there:

Sadly the Bob Swift CLI add-on that can selectively delete page versions has problems with our authentication and before I wait another year for our IT to solve that:

I found a really ugly, but straight-forward kludge:  
iMacros browser extension (I used the FF one) three-liner (if you already are on the respective history page):

```
TAB T=1TAG POS=2 TYPE=A ATTR=TXT:DeleteTAG POS=1 TYPE=BUTTON ATTR=TXT:Delete
```

Set the Loop Max and Manage \> Settings \> Timeout sufficiently high.

No worries, the script will err when there is no Delete button any more, so the current one will be preserved.

No problem to adapt that to leave some versions,...

**Atlassian** , please answer the question above!!!  
Thanks  
G.


Answers:
author: lavitz slambert
body: I'm not from atlassian but I can reply that one :smile:. When you delete a page version from page history section that information is also removed from the database together with all the child table references. As a prof of concept check the below test and outputs I've made against Confluence 5.8.4:

1. Lest' create a page called "test page" and add an attachment (know how.txt) on the creation of that page.
2. Now let's modify the page more two times.
3. Now in the page history session we have 3 versions for our test page.
4. After that we will run below queries:

   img.jpg
5. In above image you can see 3 lines representing each version of your page plus one additional line representing the attachment we added.

6. Now let's go to page history and remove the two first versions of the page and run those queries again:  
   img2.jpg
7. See that the previous two lines where removed? Also the line representing the attachment will remain as the attachment is still present in the latest page of our test.

Hope this give you a better input on how Confluence works on the database level.  
Thanks and Regards,  
Lavitz - the guy that uses Confluence on Windows as a Hobby!  
[](https://community.atlassian.com/t5/Confluence-questions/Bulk-delete-purge-Confluence-page-history-versions/qaq-p/64050?attachment-id=9156){#link_11883cb3e75b75}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/10892/1/img.jpg){#display_11883cb3e75b75_0}  
[](https://community.atlassian.com/t5/Confluence-questions/Bulk-delete-purge-Confluence-page-history-versions/qaq-p/64050?attachment-id=9157){#link_11883cb3e75b75_0}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/10892/2/img2.jpg){#display_11883cb3e75b75_2}

comments: author: Guenter Huber
body: Sounds reasonable, Lambert. Thanks for jumping in!What the SQL DB does with the records marked for deletion is a whole other story, but there are recipes to reclaim the space.IAC there will be much less trash when I copy the space next time.Did you try SQL to delete history?Confluence as a hobby? Can?t say what I think.Thanks againG.


author: lavitz slambert
body: You are more than welcome :D. Never deleted the history manually as there's might be other tasks or attachments to delete depending on the content of the page (kinda risky). Yep, sometimes confluence is a pain in the @#$, but I do have some fun as well when checking the database structure.


author: Doug
body: I used iMacros last year to reduce a large amount of page versions. This macro code will allow deleting the oldest version to then be able to loop for a set number of times that would then leave the X most recent page versions. It was my goal to leave pages with at least 10 page versions and a minimum of a week of history.

```
TAG POS=1 TYPE=TD ATTR=TXT:"v. 1"TAG POS=R1 TYPE=A ATTR=TXT:"Delete"?TAG POS=1 TYPE=BUTTON ATTR=TXT:Delete
```

This year I used the Bob Swift CLI to remove the page versions, which saved hours of time. I too had the authentication problem, but we got around it by installing the CLI Client on the Confluence box and used ssh to run the commands.


author: Guenter Huber
body: > Doug:  
> This year I used the Bob Swift CLI to remove the page versions, which saved hours of time. **I too had the authentication problem, but we got around it by installing the CLI Client on the Confluence box and used ssh to run the commands.**

Thanks, Doug, that was exactly the answer I was looking for!!!  
Sadly I couldn?t find a way to convert your comment to an answer, so I did it with the quote.  
If you can accomplish this with yours, please do!

I cross-linked this on the [BobSwift issue](https://bobswift.atlassian.net/browse/CSOAP-410?focusedCommentId=31113&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-31113) I had opened for that.

Thanks again  
G.

comments: author: Doug
body: Glad I could help.