I need to decommission a wiki. The users would like to extract all attachments from the wiki beforehand. I've seen this post:
but the approach described would be very labour intensive for an entire wiki. I was wondering if there is any way to extract PDFs as PDF, Word files as Docx, PowerPoints as Pptx, etc?
Confluence Server V5.5.2 (I know...)
Thanks - Keith Stephens
Try this python script: https://github.com/rtphokie/confluence_attachment_extract
It takes and XML export, parses it and copies out the attachment files with their original filenames placing them in directories named for the pages the file was attached to.
OK, raised a support ticket with Confluence (https://getsupport.atlassian.com/servicedesk/customer/portal/14/CSP-230358) and got a very helpful response.
The long & the short of it is that the SQL at the bottom of this post can be used to get the full path of each attachment and generate a series of copy statements that can be posted into a DOS prompt to get the attachments out of the wiki.
I hadn't appreciated that the file system of the wiki will show just a numbered file for each attachment (and version of the attachment) but doesn't show the type of file. The query extracts the type of file as well.
Remember, my wiki is V5.5.2 and the query will need to be adjusted for later versions of Confluence, but it should provide a start.
Needless to say, I copied the database & attachment folder from the production wiki to a dev SQL Server....
Sample copy statement generated:
copy /y C:\ewiki\confluence\data\attachments\ver003\0\137\3637250\204\158\3408454\10158083\1 "C:\ewiki\Attachments\FWADecisions25May11.doc"
SQL:
Select
Concat(
'copy /y ', 'C:\ewiki\confluence\data\attachments\ver003\',
spc.SPACEID % 250,
'\',
FLOOR(spc.SPACEID / 1000) % 250,
'\',
spc.SPACEID,
'\',
att.PAGEID % 250,
'\',
FLOOR(att.PAGEID / 1000) % 250,
'\',
att.PAGEID,
'\',
Case
When att.PREVVER is NULL Then att.ATTACHMENTID
Else att.PREVVER
End,
'\',
att.ATTVERSION,
' "',
'C:\ewiki\Attachments\',
att.TITLE,
'"'
) As DiskLoc
From
usr_externalwiki.SPACES As spc
Inner Join usr_externalwiki.CONTENT As cnt
On spc.SPACEID = cnt.SPACEID
Inner Join usr_externalwiki.ATTACHMENTS As att
On cnt.CONTENTID = att.PAGEID
Where
spc.SPACEID is not null
And spc.SPACESTATUS = 'CURRENT'
And cnt.CONTENTTYPE = 'PAGE'
And cnt.PREVVER is null
And cnt.CONTENT_STATUS = 'current' --when uncommented will include only the most recent version of the attachment
And att.PREVVER is null
Order by 1
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
it's not perfect but did you think about using a WebDAV solutiong like mentioned in this ticket.
I know it would be great if you could just use the space attachements macro and have a simple download button there...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the response. I believe WebDAV is deprecated.
The space attachments macro may be worth a look, but in this wiki it's fairly obvious where the attachments are. I'm just trying to save the drudge work by having a nice simple way of getting them all out.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
totally agree with you according WebDAV - but as there is no Download Button in Space attachments macro (like it is in site attachments macro...) it may be the fastest solution to get them out.
If you find a good solution would be great to let me know.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.