2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-11 21:04:42 +08:00

FEATURE: Multisite support for S3 backup store (#6700)

This commit is contained in:
Gerhard Schlager 2018-12-05 03:10:39 +01:00 committed by Guo Xiang Tan
parent ba762ea87f
commit 99117d664c
6 changed files with 147 additions and 32 deletions

View file

@ -5,11 +5,12 @@ module BackupRestore
class S3BackupStore < BackupStore
DOWNLOAD_URL_EXPIRES_AFTER_SECONDS ||= 15
UPLOAD_URL_EXPIRES_AFTER_SECONDS ||= 21_600 # 6 hours
MULTISITE_PREFIX = "backups"
def initialize(opts = {})
s3_options = S3Helper.s3_options(SiteSetting)
s3_options.merge!(opts[:s3_options]) if opts[:s3_options]
@s3_helper = S3Helper.new(SiteSetting.s3_backup_bucket, '', s3_options)
@s3_helper = S3Helper.new(s3_bucket_name_with_prefix, '', s3_options)
end
def remote?
@ -91,5 +92,13 @@ module BackupRestore
def cleanup_allowed?
!SiteSetting.s3_disable_cleanup
end
def s3_bucket_name_with_prefix
if Rails.configuration.multisite
File.join(SiteSetting.s3_backup_bucket, MULTISITE_PREFIX, RailsMultisite::ConnectionManagement.current_db)
else
SiteSetting.s3_backup_bucket
end
end
end
end