mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 20:12:45 +08:00
FEATURE: Add --sql-only
option to discourse backup (#30009)
This change allows backup CLI user to explicitly exclude uploads from the generated backup
This commit is contained in:
parent
60826162b5
commit
8e2505c0e0
|
@ -73,10 +73,21 @@ class DiscourseCLI < Thor
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "backup", "Backup a discourse forum"
|
desc "backup", "Backup a discourse forum"
|
||||||
option :s3_uploads, type: :boolean, default: false, desc: "Include s3 uploads in the backup"
|
option :s3_uploads,
|
||||||
|
type: :boolean,
|
||||||
|
default: false,
|
||||||
|
desc: "Include s3 uploads in the backup (ignored when --sql-only is used)"
|
||||||
|
option :sql_only,
|
||||||
|
type: :boolean,
|
||||||
|
default: false,
|
||||||
|
desc: "SQL-only, exclude uploads from the backup"
|
||||||
def backup(filename = nil)
|
def backup(filename = nil)
|
||||||
load_rails
|
load_rails
|
||||||
|
|
||||||
|
if options[:sql_only] && options[:s3_uploads]
|
||||||
|
puts "--sql-only flag overrides --s3-uploads. S3 uploads will not be included in the backup."
|
||||||
|
end
|
||||||
|
|
||||||
store = BackupRestore::BackupStore.create
|
store = BackupRestore::BackupStore.create
|
||||||
|
|
||||||
if filename
|
if filename
|
||||||
|
@ -91,12 +102,16 @@ class DiscourseCLI < Thor
|
||||||
end
|
end
|
||||||
|
|
||||||
old_include_s3_uploads_in_backups = SiteSetting.include_s3_uploads_in_backups
|
old_include_s3_uploads_in_backups = SiteSetting.include_s3_uploads_in_backups
|
||||||
SiteSetting.include_s3_uploads_in_backups = true if options[:s3_uploads]
|
SiteSetting.include_s3_uploads_in_backups = true if !options[:sql_only] && options[:s3_uploads]
|
||||||
|
|
||||||
begin
|
begin
|
||||||
puts "Starting backup..."
|
puts "Starting backup..."
|
||||||
backuper =
|
backuper =
|
||||||
BackupRestore::Backuper.new(Discourse.system_user.id, filename: filename_without_extension)
|
BackupRestore::Backuper.new(
|
||||||
|
Discourse.system_user.id,
|
||||||
|
filename: filename_without_extension,
|
||||||
|
with_uploads: !options[:sql_only],
|
||||||
|
)
|
||||||
backup_filename = backuper.run
|
backup_filename = backuper.run
|
||||||
exit(1) unless backuper.success
|
exit(1) unless backuper.success
|
||||||
|
|
||||||
|
@ -126,7 +141,14 @@ class DiscourseCLI < Thor
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "export", "Backup a Discourse forum"
|
desc "export", "Backup a Discourse forum"
|
||||||
option :s3_uploads, type: :boolean, default: false
|
option :s3_uploads,
|
||||||
|
type: :boolean,
|
||||||
|
default: false,
|
||||||
|
desc: "Include s3 uploads in the backup (ignored when --sql-only is used)"
|
||||||
|
option :sql_only,
|
||||||
|
type: :boolean,
|
||||||
|
default: false,
|
||||||
|
desc: "SQL-only, exclude uploads from the backup"
|
||||||
def export(filename = nil)
|
def export(filename = nil)
|
||||||
backup(filename)
|
backup(filename)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user