Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split cleanups from backups, so the one doesn't hold up the other #450

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@

job_type :rake, "cd :path && SOLR_ENV=:environment HOST=:host bundle exec rake :task"

every 1.day, roles: [:db] do
# Default time is midnight UTC, which is:
# 7pm EST / 6pm EDT the evening before
# 4pm PST / 3pm PDT the afternoon before
every 1.day, roles: [:main] do
rake "pul_solr:backup"
end

# Default time is midnight UTC, which is:
# 7pm EST / 6pm EDT the evening before
# 4pm PST / 3pm PDT the afternoon before
every 1.day, roles: [:main] do
rake "pul_solr:cleanup"
end
1 change: 1 addition & 0 deletions lib/pul_solr/backup_manager.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'net/http'
require 'logger'
require 'json'
require 'date'

module PulSolr
class BackupManager
Expand Down
11 changes: 10 additions & 1 deletion lib/tasks/pul_solr.rake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@ namespace :pul_solr do
abort "usage: rake pul_solr:backup HOST=solr8 SOLR_ENV=[production|staging]" unless (allowed_targets.include?(target) && allowed_hosts.include?(host))
logger = Logger.new("/tmp/solr_backup.log", "monthly")
backup_manager = PulSolr::BackupManager.new(host: host, solr_env: target, logger: logger)
backup_manager.cleanup_old_backups
backup_manager.backup
end

desc "clean up old collections on solrcloud server"
task "cleanup" do
target = ENV["SOLR_ENV"]
host = ENV["HOST"]
abort "usage: rake pul_solr:cleanup HOST=solr8 SOLR_ENV=[production|staging]" unless (allowed_targets.include?(target) && allowed_hosts.include?(host))
logger = Logger.new("/tmp/solr_backup.log", "monthly")
backup_manager = PulSolr::BackupManager.new(host: host, solr_env: target, logger: logger)
backup_manager.cleanup_old_backups
end

desc "copies files from another project that has been checked out locally"
task :sync do
from_dir = ENV["FROM_DIR"]
Expand Down