Last active
August 28, 2020 01:33
-
-
Save SamSaffron/0a6e22a553fce6b4112112be4770cda9 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# This runbook is used to debug and correct situations where uploads are missing from | |
# S3. | |
# | |
# It will prompt you to delete missing uploads if any are found. | |
# | |
# Be careful, the actions it takes are destructive, BUT you will have to approve them | |
# for them to happen | |
require_relative '../lib/mini_book' | |
SITE_NAME = Args.lookup( | |
site: :required | |
) | |
step("Lookup site from site name") do | |
@site = Site.lookup(SITE_NAME) | |
end | |
step("Download latest uploads rake tasks, in case running an old Discourse version") do | |
@site.container.download( | |
'https://raw.githubusercontent.com/discourse/discourse/master/lib/tasks/uploads.rake', | |
'/var/www/discourse/lib/tasks/uploads.rake' | |
) | |
end | |
step("Run fix missing s3 job - will attempt to download all missing s3 uploads from source") do | |
@site.rake "uploads:fix_missing_s3" | |
end | |
step("Run analysis on missing s3 uploads") do | |
@site.rake "uploads:analyze_missing_s3" | |
end | |
step("Delete uploads missing from s3") do | |
@site.rake "uploads:delete_missing_s3" | |
end | |
step("Run S3 inventory on #{@site.name}") do | |
@site.runner "Jobs::EnsureS3UploadsExistence.new.execute(nil)" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment