Skip to content

Instantly share code, notes, and snippets.

@rswaminathan
Created August 2, 2022 20:59
Show Gist options
  • Save rswaminathan/b0a158e97721feeac37bc823c33bd228 to your computer and use it in GitHub Desktop.
Save rswaminathan/b0a158e97721feeac37bc823c33bd228 to your computer and use it in GitHub Desktop.
Confluence Content Recovery from Database
require 'csv'
require 'pathname'
txt = File.open('backup-bible-content.txt').read #dump of `bodycontent` table in txt format
blobs = txt.split("\t")
cols = []
blobs[4..-1].each_slice(3) {|arr| cols << arr} #0 -> content, 1-> contentid
CSV.open('bible-pages.csv').each do |row| #dump of `pages` table in csv format
content_id, _ , title = row
content = cols.find {|a| a[1] == content_id }&.[](0)
path = Pathname("pages/#{title}.html")
path.dirname.mkpath
path.write(content) if content
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment