Skip to content

Commit

Permalink
fd python libcloud plugin: put number of backed-up objects to joblog
Browse files Browse the repository at this point in the history
- add optional parameter "job_message_after_number_of_objects" to libcloud config
- put a jobmessage after each count of "job_message_after_number_of_objects" to the
  joblog or no message if parameter equals 0; default is 100

- renamed a variable
  • Loading branch information
franku committed Nov 3, 2020
1 parent e26819b commit 54276c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
28 changes: 23 additions & 5 deletions core/src/plugins/filed/python/libcloud/BareosFdPluginLibcloud.py
Expand Up @@ -96,6 +96,7 @@ def __init__(self, plugindef):
super(BareosFdPluginLibcloud, self).__init__(plugindef)
super(BareosFdPluginLibcloud, self).parse_plugin_definition(plugindef)
self.options["fail_on_download_error"] = False
self.options["job_message_after_each_number_of_objects"] = 100
self.__parse_options()

self.last_run = datetime.datetime.fromtimestamp(self.since)
Expand All @@ -105,7 +106,7 @@ def __init__(self, plugindef):
# Set to None when the whole backup is completed
# Restore's path will not touch this
self.current_backup_task = {}
self.number_of_objects_to_backup = 0
self.number_of_objects_have_been_backed_up = 0
self.FILE = None
self.active = True
self.api = None
Expand Down Expand Up @@ -167,7 +168,10 @@ def __check_config(self, config_filename):
"temporary_download_directory",
]
optional_options = {}
optional_options["misc"] = ["fail_on_download_error"]
optional_options["misc"] = [
"fail_on_download_error",
"job_message_after_each_number_of_objects",
]

# this maps config file options to libcloud options
option_map = {
Expand Down Expand Up @@ -223,7 +227,10 @@ def __check_config(self, config_filename):
if self.config.has_option(section, option):
try:
value = self.config.get(section, option)
self.options["fail_on_download_error"] = strtobool(value)
if option == "fail_on_download_error":
self.options["fail_on_download_error"] = strtobool(value)
elif option == "job_message_after_each_number_of_objects":
self.options["job_message_after_each_number_of_objects"] = int(value)
except:
debugmessage(
100,
Expand Down Expand Up @@ -282,7 +289,7 @@ def __shutdown(self):
jobmessage(
M_INFO,
"BareosFdPluginLibcloud finished with %d files"
% (self.number_of_objects_to_backup),
% (self.number_of_objects_have_been_backed_up),
)

if self.api == None:
Expand Down Expand Up @@ -478,7 +485,18 @@ def plugin_io(self, IOP):

def end_backup_file(self):
if self.current_backup_task is not None:
self.number_of_objects_to_backup += 1
self.number_of_objects_have_been_backed_up += 1
if self.options["job_message_after_each_number_of_objects"] != 0:
if (
self.number_of_objects_have_been_backed_up
% self.options["job_message_after_each_number_of_objects"]
== 0
):
jobmessage(
M_INFO,
"Number of backed-up objects: %d"
% self.number_of_objects_have_been_backed_up,
)
return bRC_More
else:
return bRC_OK
3 changes: 3 additions & 0 deletions docs/manuals/source/TasksAndConcepts/Plugins.rst
Expand Up @@ -1640,6 +1640,9 @@ fail_on_download_error
When this option is enabled, any error during a file download will fail the backup job.
By default a warning will be issued and the next file will be backed up.

job_message_after_each_number_of_objects
When running a backup, put a jobmessage after each count of "job_message_after_number_of_objects"
to the joblog or no message if parameter equals 0; default is 100.

.. _PerconaXtrabackupPlugin:
.. _backup-mysql-XtraBackup:
Expand Down
Expand Up @@ -13,3 +13,4 @@ nb_worker=20
queue_size=1000
prefetch_size=250*1024
temporary_download_directory=/dev/shm/bareos_libcloud
job_message_after_each_number_of_objects=10

0 comments on commit 54276c4

Please sign in to comment.