diff --git a/lib/tasks/bvfs_cleanup.rake b/lib/tasks/bvfs_cleanup.rake index c0f4184..535e113 100644 --- a/lib/tasks/bvfs_cleanup.rake +++ b/lib/tasks/bvfs_cleanup.rake @@ -1,17 +1,18 @@ namespace :bvfs do desc 'Cleans up the restore database' task cleanup: :environment do - for_purge = ActiveRecord::Base.connection.tables.select do |name| + for_purge = ActiveRecord::Base.establish_connection(BACULA_CONF).connection.tables. + select do |name| match_data = name.match(/^b2\d+(\d{12}$)/) match_data.present? && match_data[1].present? && match_data[1] < (Archiving.settings[:temp_db_retention].ago.to_f * 100).to_i.to_s end for_purge.each do |dbname| Bvfs.new(nil,[]).purge_db(dbname) end Rails.logger.warn("[BVFS]: Cleaned up dbs: #{for_purge.join(', ')}") end end