For now, some useful scripts and steps related to Atlassian Confluence can be stored here…
SQL Server script to re-attach personal spaces that are missing after an upgrade:
update SPACES set CREATOR = (select user_key from user_mapping where concat(‘~’, username) = SPACEKEY) where SPACETYPE = ‘personal’ and CREATOR is null;
For more information, refer to: https://confluence.atlassian.com/confkb/personal-spaces-are-no-longer-linked-and-creator-is-anonymous-790796211.html
Scripts to avoid cross-talk to live environment after refreshing data to test:
Deleting outbound SMTP connections…
DELETE FROM BANDANA WHERE BANDANAKEY = ‘atlassian.confluence.smtp.mail.accounts’;
DELETE FROM BANDANA WHERE BANDANAKEY = ‘atlassian.confluence.space.mailaccounts’;
For more information, refer to: https://confluence.atlassian.com/doc/restoring-a-test-instance-from-production-127369720.html
Script to enumerate all labels used across all spaces:
SELECT L.NAME, CO.TITLE, SP.SPACENAME
FROM CONTENT_LABEL CL, LABEL L, CONTENT CO, SPACES SP
WHERE CL.LABELID = L.LABELID AND CO.CONTENTID = CL.CONTENTID AND SP.SPACEID = CO.SPACEID
Script to find and replace a string with another string across all pages:
UPDATE dbo.BODYCONTENT
SET BODY = CAST(REPLACE(CAST(BODY as nvarchar(max)),’originalTextToFind’,
‘newTextInItsPlace’) as ntext);