mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06: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
|
||||
|
||||
unpause_sidekiq
|
||||
|
||||
disable_readonly_mode
|
||||
### READ-ONLY / END ###
|
||||
|
||||
log "Finalizing backup..."
|
||||
|
||||
@with_uploads ? create_archive : move_dump_backup
|
||||
|
||||
unpause_sidekiq
|
||||
upload_archive
|
||||
|
||||
after_create_hook
|
||||
@ -237,8 +237,8 @@ module BackupRestore
|
||||
FileUtils.cd(File.join(Rails.root, "public")) do
|
||||
if File.directory?(upload_directory)
|
||||
Discourse::Utils.execute_command(
|
||||
'tar', '--append', '--dereference', '--warning=no-file-changed', '--file', tar_filename, upload_directory,
|
||||
failure_message: "Failed to archive uploads."
|
||||
'tar', '--append', '--dereference', '--file', tar_filename, upload_directory,
|
||||
failure_message: "Failed to archive uploads.", success_status_codes: [0, 1]
|
||||
)
|
||||
else
|
||||
log "No uploads found, skipping archiving uploads..."
|
||||
|
@ -21,10 +21,10 @@ module Discourse
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
if !status.success?
|
||||
if !status.exited? || !success_status_codes.include?(status.exitstatus)
|
||||
failure_message = "#{failure_message}\n" if !failure_message.blank?
|
||||
raise "#{caller[0]}: #{failure_message}#{stderr}"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user