lib/backup/database/redis.rb in backup-3.0.19 vs lib/backup/database/redis.rb in backup-3.0.20

- old
+ new

@@ -32,11 +32,10 @@ load_defaults! @additional_options ||= Array.new instance_eval(&block) - prepare! end ## # Builds the Redis credentials syntax to authenticate the user # to perform the database dumping process @@ -71,32 +70,41 @@ # to copy the persisted Redis dump file to the Backup archive. # Additionally, when 'invoke_save' is set to true, it'll tell # the Redis server to persist the current state to the dump file # before copying the dump to get the most recent updates in to the backup def perform! - log! + super invoke_save! if invoke_save copy! end ## # Tells Redis to persist the current state of the # in-memory database to the persisted dump file def invoke_save! - response = run("#{ utility('redis-cli') } #{ credential_options } #{ connectivity_options } #{ additional_options } SAVE") + response = run("#{ utility('redis-cli') } #{ credential_options } " + + "#{ connectivity_options } #{ additional_options } SAVE") unless response =~ /OK/ - Logger.error "Could not invoke the Redis SAVE command. The #{ database } file might not contain the most recent data." - Logger.error "Please check if the server is running, the credentials (if any) are correct, and the host/port/socket are correct." + raise Errors::Database::Redis::CommandError, <<-EOS + Could not invoke the Redis SAVE command. + The #{ database } file might not contain the most recent data. + Please check if the server is running, the credentials (if any) are correct, + and the host/port/socket are correct. + + Redis CLI response: #{ response } + EOS end end ## # Performs the copy command to copy over the Redis dump file to the Backup archive def copy! unless File.exist?(File.join(path, database)) - Logger.error "Redis database dump not found in '#{ File.join(path, database) }'" - exit + raise Errors::Database::Redis::NotFoundError, <<-EOS + Redis database dump not found + File path was #{ File.join(path, database) } + EOS end # Temporarily remove a custom `utility_path` setting so that the system # `cp` utility can be found, then restore the old value just in case. old_path, self.utility_path = self.utility_path, nil