Created
August 2, 2022 20:59
-
-
Save rswaminathan/b0a158e97721feeac37bc823c33bd228 to your computer and use it in GitHub Desktop.
Confluence Content Recovery from Database
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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