mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 16:17:54 +08:00
FIX: Unpause sidekiq before adding uploads to backup
tar exits with status 1 when uploads are modified or deleted by a sidekiq job, so we need to treat it like status 0. According to the documentation it should be safe to ignore status 1 ("Some files differ"): > If tar was given `--create', `--append' or `--update' option, this exit code means that some files were changed while being archived and so the resulting archive does not contain the exact copy of the file set. Status 2 ("Fatal error") still results in an exception.
This commit is contained in:
parent
b8b1759de9
commit
220944a38a
@ -37,14 +37,14 @@ module BackupRestore
|
|||||||
|
|
||||||
dump_public_schema
|
dump_public_schema
|
||||||
|
|
||||||
|
unpause_sidekiq
|
||||||
|
|
||||||
disable_readonly_mode
|
disable_readonly_mode
|
||||||
### READ-ONLY / END ###
|
### READ-ONLY / END ###
|
||||||
|
|
||||||
log "Finalizing backup..."
|
log "Finalizing backup..."
|
||||||
|
|
||||||
@with_uploads ? create_archive : move_dump_backup
|
@with_uploads ? create_archive : move_dump_backup
|
||||||
|
|
||||||
unpause_sidekiq
|
|
||||||
upload_archive
|
upload_archive
|
||||||
|
|
||||||
after_create_hook
|
after_create_hook
|
||||||
@ -237,8 +237,8 @@ module BackupRestore
|
|||||||
FileUtils.cd(File.join(Rails.root, "public")) do
|
FileUtils.cd(File.join(Rails.root, "public")) do
|
||||||
if File.directory?(upload_directory)
|
if File.directory?(upload_directory)
|
||||||
Discourse::Utils.execute_command(
|
Discourse::Utils.execute_command(
|
||||||
'tar', '--append', '--dereference', '--warning=no-file-changed', '--file', tar_filename, upload_directory,
|
'tar', '--append', '--dereference', '--file', tar_filename, upload_directory,
|
||||||
failure_message: "Failed to archive uploads."
|
failure_message: "Failed to archive uploads.", success_status_codes: [0, 1]
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
log "No uploads found, skipping archiving uploads..."
|
log "No uploads found, skipping archiving uploads..."
|
||||||
|
@ -21,10 +21,10 @@ module Discourse
|
|||||||
end
|
end
|
||||||
|
|
||||||
class Utils
|
class Utils
|
||||||
def self.execute_command(*command, failure_message: "")
|
def self.execute_command(*command, failure_message: "", success_status_codes: [0])
|
||||||
stdout, stderr, status = Open3.capture3(*command)
|
stdout, stderr, status = Open3.capture3(*command)
|
||||||
|
|
||||||
if !status.success?
|
if !status.exited? || !success_status_codes.include?(status.exitstatus)
|
||||||
failure_message = "#{failure_message}\n" if !failure_message.blank?
|
failure_message = "#{failure_message}\n" if !failure_message.blank?
|
||||||
raise "#{caller[0]}: #{failure_message}#{stderr}"
|
raise "#{caller[0]}: #{failure_message}#{stderr}"
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user