Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support backup of mariadb using mariabackup #967

Merged
merged 2 commits into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -52,6 +52,7 @@ debian/bareos-filedaemon-ceph-plugin.install
debian/bareos-filedaemon-glusterfs-plugin.install
debian/bareos-filedaemon-ldap-python-plugin.install
debian/bareos-filedaemon-libcloud-python-plugin.install
debian/bareos-filedaemon-mariabackup-python-plugin.install
debian/bareos-filedaemon-percona-xtrabackup-python-plugin.install
debian/bareos-filedaemon-python-plugin.install
debian/bareos-filedaemon-python-plugins-common.install
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -97,6 +97,8 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- contrib: Add Python FD Plugin for OpenVZ container [PR #908]
- packages: Build also for Fedora_35 [PR #972]
- cmake: check for chflags() function and enable FreeBSD File Flags support [PR #963]
- plugin: added mariabackup python plugin, added systemtest for mariabackup and updated systemtest for percona-xtrabackup [PR #967]


### Changed
- systemtest python-bareos: split tests in separate files [PR #944]
Expand Down
1 change: 0 additions & 1 deletion core/CMakeLists.txt
Expand Up @@ -935,7 +935,6 @@ message(" MTX: ${MTX}")
message(" MT: ${MT}")
message(" MINIO: ${MINIO}")
message(" S3CMD: ${S3CMD}")
message(" XTRABACKUP: ${XTRABACKUP}")
message(" DEVELOPER: ${developer}")
message(" LocalBuildDefinitionsFile: ${BareosLocalBuildDefinitionsFile}")
message(" HAVE_IS_TRIVIALLY_COPYABLE: ${HAVE_IS_TRIVIALLY_COPYABLE}")
Expand Down
74 changes: 69 additions & 5 deletions core/cmake/BareosFindPrograms.cmake
Expand Up @@ -60,14 +60,9 @@ find_program(GCORE gcore)
find_program(GDB gdb)
find_program(DBX dbx)
find_program(MDB mdb)
find_program(XTRABACKUP xtrabackup)
find_program(S3CMD s3cmd)
find_program(MINIO minio)

find_program(MYSQL mysql)
find_program(MYSQLD mysqld PATH /opt/mysql/bin)
find_program(MYSQL_INSTALL_DB mysql_install_db)

if(POLICY CMP0109)
cmake_policy(SET CMP0109 NEW)
find_program(SUDO sudo)
Expand All @@ -77,3 +72,72 @@ else()
PARENT_SCOPE
)
endif(POLICY CMP0109)

# To test backups of mysql with percona xtrabackup, and mariadb with
# mariabackup, we need to find the specific binaries in order to run our test
# databases:

# For mysql: XTRABACKUP_BINARY MYSQL_DAEMON_BINARY MYSQL_CLIENT_BINARY

if(NOT DEFINED XTRABACKUP_BINARY)
find_program(XTRABACKUP_BINARY xtrabackup)
endif()

macro(find_program_and_verify_version_string variable program
version_substr_wanted path_to_search no_default_path
)

string(TOUPPER ${program} program_uppercase)
message(CHECK_START
"Looking for ${program} in version ${version_substr_wanted}"
)
list(APPEND CMAKE_MESSAGE_INDENT " ")
find_program(${variable} ${program} PATH ${path_to_search} ${no_default_path})
if(${variable})
execute_process(
COMMAND ${${variable}} --version
OUTPUT_VARIABLE VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "CANDIDATE IS ${VERSION_STRING}")
if(${VERSION_STRING} MATCHES ${version_substr_wanted})
message(CHECK_PASS "OK")
else()
message(CHECK_PASS "NOT OK: it is not ${version_substr_wanted}")
unset(${variable})
endif()
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT " ")
endmacro()

find_program_and_verify_version_string(MYSQL_DAEMON_BINARY mysqld MySQL "" "")
find_program_and_verify_version_string(MYSQL_CLIENT_BINARY mysql MySQL "" "")

message(STATUS "XTRABACKUP_BINARY: ${XTRABACKUP_BINARY}")
message(STATUS "MYSQL_DAEMON_BINARY:${MYSQL_DAEMON_BINARY}")
message(STATUS "MYSQL_CLIENT_BINARY:${MYSQL_CLIENT_BINARY}")

# For mariadb: MARIABACKUP_BINARY MARIADB_DAEMON_BINARY MARIADB_CLIENT_BINARY
# MARIADB_MYSQL_INSTALL_DB_SCRIPT

if(NOT DEFINED MARIABACKUP_BINARY)
find_program(MARIABACKUP_BINARY mariabackup)
endif()

find_program_and_verify_version_string(
MARIADB_DAEMON_BINARY mysqld MariaDB "/usr/libexec" ""
)
find_program_and_verify_version_string(
MARIADB_CLIENT_BINARY mysql MariaDB "" ""
)

if(NOT DEFINED MARIADB_MYSQL_INSTALL_DB_SCRIPT)
find_program(MARIADB_MYSQL_INSTALL_DB_SCRIPT mysql_install_db)
endif()

message(STATUS "MARIABACKUP_BINARY: ${MARIABACKUP_BINARY}")
message(STATUS "MARIADB_DAEMON_BINARY:${MARIADB_DAEMON_BINARY}")
message(STATUS "MARIADB_CLIENT_BINARY: ${MARIADB_CLIENT_BINARY}")
message(
STATUS "MARIADB_MYSQL_INSTALL_DB_SCRIPT: ${MARIADB_MYSQL_INSTALL_DB_SCRIPT}"
)
29 changes: 20 additions & 9 deletions core/platforms/packaging/bareos.spec
Expand Up @@ -589,7 +589,13 @@ Summary: Percona xtrabackup Python plugin for Bareos File daemon
Group: Productivity/Archiving/Backup
Requires: bareos-filedaemon = %{version}
Requires: bareos-filedaemon-python-plugin = %{version}
#Requires: python-percona

%package filedaemon-mariabackup-python-plugin
Summary: Mariabackup Python plugin for Bareos File daemon
Group: Productivity/Archiving/Backup
Requires: bareos-filedaemon = %{version}
Requires: bareos-filedaemon-python-plugin = %{version}


%package storage-python2-plugin
Summary: Python plugin for Bareos Storage daemon
Expand Down Expand Up @@ -701,11 +707,18 @@ This package contains the Libcloud python plugin for the file daemon
%{dscr}

This package contains the PostgreSQL python plugin for the file daemon

%description filedaemon-percona-xtrabackup-python-plugin
%{dscr}

This package contains the Percona python plugin for the file daemon

%description filedaemon-mariabackup-python-plugin
%{dscr}

This package contains the Mariabackup python plugin for the file daemon


%description storage-python2-plugin
%{dscr}

Expand Down Expand Up @@ -1656,9 +1669,12 @@ mkdir -p %{?buildroot}/%{_libdir}/bareos/plugins/vmware_plugin
%defattr(-, root, root)
%{plugin_dir}/bareos-fd-percona-xtrabackup.py*
%{plugin_dir}/BareosFdPluginPerconaXtraBackup.py*
##attr(0640, #{director_daemon_user}, #{daemon_group}) #{_sysconfdir}/#{name}/bareos-dir.d/fileset/plugin-percona-xtrabackup.conf.example
##attr(0640, #{director_daemon_user}, #{daemon_group}) #{_sysconfdir}/#{name}/bareos-dir.d/job/backup-percona-xtrabackup.conf.example
##attr(0640, #{director_daemon_user}, #{daemon_group}) #{_sysconfdir}/#{name}/bareos-dir.d/job/restore-percona-xtrabackup.conf.example

%files filedaemon-mariabackup-python-plugin
%defattr(-, root, root)
%{plugin_dir}/bareos-fd-mariabackup.py*
%{plugin_dir}/BareosFdPluginMariabackup.py*


%files director-python2-plugin
%defattr(-, root, root)
Expand Down Expand Up @@ -1944,11 +1960,6 @@ a2enmod php5 &> /dev/null || true
%posttrans filedaemon-ldap-python-plugin
%posttrans_restore_file /etc/%{name}/bareos-dir.d/plugin-python-ldap.conf

#post filedaemon-percona-xtrabackup-python-plugin
#post_backup_file /etc/#{name}/bareos-dir.d/plugin-python-percona-xtrabackup.conf
#posttrans filedaemon-percona-xtrabackup-python-plugin
#posttrans_restore_file /etc/#{name}/bareos-dir.d/plugin-python-percona-xtrabackup.conf

%endif


Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/filed/python/CMakeLists.txt
Expand Up @@ -185,6 +185,8 @@ set(PYFILES
pyfiles/bareos-fd-local-fileset.py
ldap/bareos-fd-ldap.py
ldap/BareosFdPluginLDAP.py
mariabackup/BareosFdPluginMariabackup.py
mariabackup/bareos-fd-mariabackup.py
ovirt/bareos-fd-ovirt.py
ovirt/BareosFdPluginOvirt.py
percona-xtrabackup/bareos-fd-percona-xtrabackup.py
Expand Down