Skip to content

Commit

Permalink
Merge pull request #564 from arogge/dev/arogge/master/deprecate-mysql
Browse files Browse the repository at this point in the history
Add deprecation notifications for catalogs using mysql/sqlite3
  • Loading branch information
arogge committed Aug 7, 2020
2 parents f383677 + 2a21c54 commit fd13940
Show file tree
Hide file tree
Showing 31 changed files with 323 additions and 90 deletions.
46 changes: 46 additions & 0 deletions .gitignore
Expand Up @@ -20,6 +20,52 @@ autoconf/config.log

# debian
debian/*.log
debian/bareos-bconsole.install
debian/bareos-bconsole.postinst
debian/bareos-common.postinst
debian/bareos-common.preinst
debian/bareos-database-common.config
debian/bareos-database-common.install
debian/bareos-database-common.postinst
debian/bareos-database-mysql.install
debian/bareos-database-postgresql.dirs
debian/bareos-director.install
debian/bareos-database-sqlite3.install
debian/bareos-devel.install
debian/bareos-director-python-plugin.install
debian/bareos-director.bareos-dir.init
debian/bareos-common.install
debian/bareos-director.postinst
debian/bareos-director.preinst
debian/bareos-director.service
debian/bareos-filedaemon-ceph-plugin.install
debian/bareos-filedaemon-glusterfs-plugin.install
debian/bareos-filedaemon-ldap-python-plugin.install
debian/bareos-filedaemon-python-plugin.install
debian/bareos-filedaemon.bareos-fd.init
debian/bareos-filedaemon.install
debian/bareos-filedaemon.postinst
debian/bareos-filedaemon.preinst
debian/bareos-filedaemon.service
debian/bareos-regress-config.install
debian/bareos-regress-config.preinst
debian/bareos-storage-ceph.install
debian/bareos-storage-fifo.install
debian/bareos-storage-glusterfs.install
debian/bareos-storage-python-plugin.install
debian/bareos-storage-tape.install
debian/bareos-storage.bareos-sd.init
debian/bareos-storage.install
debian/bareos-storage.postinst
debian/bareos-storage.preinst
debian/bareos-storage.service
debian/bareos-tools.install
debian/bareos-traymonitor.install
debian/bareos-traymonitor.postinst
debian/univention-bareos.postinst
debian/bareos-database-postgresql.install
debian/bareos-database-tools.install
debian/bareos-filedaemon-percona-xtrabackup-python-plugin.install

# etags and cscope db
tags
Expand Down
47 changes: 0 additions & 47 deletions core/.gitignore
@@ -1,50 +1,3 @@
debian/bareos-bconsole.install
debian/bareos-bconsole.postinst
debian/bareos-common.postinst
debian/bareos-common.preinst
debian/bareos-database-common.config
debian/bareos-database-common.install
debian/bareos-database-common.postinst
debian/bareos-database-mysql.install
debian/bareos-database-postgresql.dirs
debian/bareos-director.install
debian/bareos-database-sqlite3.install
debian/bareos-devel.install
debian/bareos-director-python-plugin.install
debian/bareos-director.bareos-dir.init
debian/bareos-common.install
debian/bareos-director.postinst
debian/bareos-director.preinst
debian/bareos-director.service
debian/bareos-filedaemon-ceph-plugin.install
debian/bareos-filedaemon-glusterfs-plugin.install
debian/bareos-filedaemon-ldap-python-plugin.install
debian/bareos-filedaemon-python-plugin.install
debian/bareos-filedaemon.bareos-fd.init
debian/bareos-filedaemon.install
debian/bareos-filedaemon.postinst
debian/bareos-filedaemon.preinst
debian/bareos-filedaemon.service
debian/bareos-regress-config.install
debian/bareos-regress-config.preinst
debian/bareos-storage-ceph.install
debian/bareos-storage-fifo.install
debian/bareos-storage-glusterfs.install
debian/bareos-storage-python-plugin.install
debian/bareos-storage-tape.install
debian/bareos-storage.bareos-sd.init
debian/bareos-storage.install
debian/bareos-storage.postinst
debian/bareos-storage.preinst
debian/bareos-storage.service
debian/bareos-tools.install
debian/bareos-traymonitor.install
debian/bareos-traymonitor.postinst
debian/control
debian/univention-bareos.postinst
debian/bareos-database-postgresql.install
debian/bareos-database-tools.install
debian/bareos-filedaemon-percona-xtrabackup-python-plugin.install
platforms/aix/bareos-fd
platforms/alpha/bareos-fd
platforms/bsdi/bareos-dir
Expand Down
9 changes: 8 additions & 1 deletion core/cmake/BareosConfigureFile.cmake
Expand Up @@ -21,7 +21,14 @@
# configure file all *.in files
#

file(GLOB_RECURSE IN_FILES "${CMAKE_SOURCE_DIR}/*.in")
# if we're not the toplevel project, then we want to glob in core and debian subdirectories only
get_directory_property(have_parent PARENT_DIRECTORY)
if(have_parent)
file(GLOB_RECURSE IN_FILES "${CMAKE_SOURCE_DIR}/core/*.in" "${CMAKE_SOURCE_DIR}/debian/*.in")
else()
file(GLOB_RECURSE IN_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.in")
endif()

foreach(in_file ${IN_FILES})
string(
REGEX
Expand Down
18 changes: 15 additions & 3 deletions core/src/dird/dird_conf.cc
Expand Up @@ -322,7 +322,7 @@ static ResourceItem cat_items[] = {
{ "User", CFG_TYPE_STR, ITEM(res_cat, db_user), 0, CFG_ITEM_ALIAS, NULL, NULL, NULL },
{ "DbName", CFG_TYPE_STR, ITEM(res_cat, db_name), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL },
#ifdef HAVE_DYNAMIC_CATS_BACKENDS
{ "DbDriver", CFG_TYPE_STR, ITEM(res_cat, db_driver), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL },
{ "DbDriver", CFG_TYPE_STR, ITEM(res_cat, db_driver), 0, CFG_ITEM_DEFAULT, "postgresql", NULL, NULL },
#else
{ "DbDriver", CFG_TYPE_STR, ITEM(res_cat, db_driver), 0, 0, NULL, NULL, NULL },
#endif
Expand Down Expand Up @@ -1260,8 +1260,8 @@ bool ValidateResource(int res_type, ResourceItem* items, BareosResource* res)
* a jobdef don't have to be fully defined.
*/
return true;
} else if (res_type == R_JOB) {
if (!((JobResource*)res)->Validate()) { return false; }
} else if (!res->Validate()) {
return false;
}

for (int i = 0; items[i].name; i++) {
Expand Down Expand Up @@ -1332,6 +1332,18 @@ bool JobResource::Validate()
return true;
}

bool CatalogResource::Validate()
{
/* during 1st pass, db_driver is nullptr and we skip the check */
if (db_driver != nullptr &&
(std::string(db_driver) == "mysql" ||
std::string(db_driver) == "sqlite3")) {
my_config->AddWarning(std::string("Deprecated DB driver ") + db_driver +
" for Catalog " + resource_name_);
}
return true;
}

char* CatalogResource::display(POOLMEM* dst)
{
Mmsg(dst,
Expand Down
3 changes: 2 additions & 1 deletion core/src/dird/dird_conf.h
Expand Up @@ -259,6 +259,7 @@ class CatalogResource : public BareosResource {
public:
CatalogResource() = default;
virtual ~CatalogResource() = default;
virtual bool Validate() override;

uint32_t db_port = 0; /**< Port */
char* db_address = nullptr; /**< Hostname for remote access */
Expand Down Expand Up @@ -535,7 +536,7 @@ class JobResource : public BareosResource {
runtime_job_status_t* rjs = nullptr; /**< Runtime Job Status */

/* Methods */
bool Validate();
virtual bool Validate() override;
};
/* clang-format on */

Expand Down
4 changes: 4 additions & 0 deletions core/src/lib/bareos_resource.cc
Expand Up @@ -48,6 +48,10 @@ BareosResource::BareosResource(const BareosResource& other)
::memcpy(inherit_content_, other.inherit_content_, MAX_RES_ITEMS);
}

bool BareosResource::Validate() {
return true;
}

BareosResource& BareosResource::operator=(const BareosResource& rhs)
{
next_ = rhs.next_;
Expand Down
2 changes: 2 additions & 0 deletions core/src/lib/bareos_resource.h
Expand Up @@ -52,6 +52,8 @@ class BareosResource {
const ConfigurationParser& my_config,
bool hide_sensitive_data = false,
bool verbose = false);

virtual bool Validate();
};

#endif /* BAREOS_LIB_BAREOS_RESOURCE_H_ */
2 changes: 1 addition & 1 deletion core/src/tests/CMakeLists.txt
Expand Up @@ -160,7 +160,7 @@ endif() # NOT client-only
if(NOT client-only)
bareos_add_test(
scheduler_job_item_queue
LINK_LIBRARIES dird_objects bareos ${GTEST_LIBRARIES}
LINK_LIBRARIES dird_objects bareos bareosfind bareoscats bareossql ${GTEST_LIBRARIES}
${GTEST_MAIN_LIBRARIES}
)
endif() # NOT client-only
Expand Down
22 changes: 22 additions & 0 deletions debian/control
Expand Up @@ -315,3 +315,25 @@ Description: Backup Archiving Recovery Open Sourced - common tools
data across a network of computers of different kinds.
.
This package provides scripts and configuration to run bareos-regress with the installed Bareos packages.






















Expand Up @@ -1943,8 +1943,8 @@
"DbDriver": {
"datatype": "STRING",
"code": 0,
"equals": true,
"required": true
"default_value": "postgresql",
"equals": true
},
"DbSocket": {
"datatype": "STRING",
Expand Down
1 change: 1 addition & 0 deletions systemtests/CMakeLists.txt
Expand Up @@ -652,6 +652,7 @@ set(SYSTEM_TESTS
config-syntax-crash
copy-bscan
copy-remote-bscan
deprecation
messages
multiplied-device
reload-add-client
Expand Down
@@ -0,0 +1,8 @@
Catalog {
Name = MyCatalog
#dbdriver = "@DEFAULT_DB_TYPE@"
dbdriver = "XXX_REPLACE_WITH_DATABASE_DRIVER_XXX"
dbname = "@db_name@"
dbuser = "@db_user@"
dbpassword = "@db_password@"
}
@@ -0,0 +1,7 @@
Client {
Name = bareos-fd
Description = "Client resource of the Director itself."
Address = @hostname@
Password = "@fd_password@" # password for FileDaemon
FD PORT = @fd_port@
}
@@ -0,0 +1,7 @@
Console {
Name = bareos-mon
Description = "Restricted console used by tray-monitor to get the status of the director."
Password = "@mon_dir_password@"
CommandACL = status, .status
JobACL = *all*
}
@@ -0,0 +1,27 @@
Director { # define myself
Name = bareos-dir
QueryFile = "@scriptdir@/query.sql"
Maximum Concurrent Jobs = 10
Password = "@dir_password@" # Console password
Messages = Daemon
Auditing = yes

# Enable the Heartbeat if you experience connection losses
# (eg. because of your router or firewall configuration).
# Additionally the Heartbeat can be enabled in bareos-sd and bareos-fd.
#
# Heartbeat Interval = 1 min

# remove comment in next line to load dynamic backends from specified directory
Backend Directory = @backenddir@

# remove comment from "Plugin Directory" to load plugins from specified directory.
# if "Plugin Names" is defined, only the specified plugins will be loaded,
# otherwise all director plugins (*-dir.so) from the "Plugin Directory".
#
# Plugin Directory = "@python_plugin_module_src_dir@"
# Plugin Names = ""
Working Directory = "@working_dir@"
Pid Directory = "@piddir@"
DirPort = @dir_port@
}
Expand Up @@ -5,7 +5,7 @@ FileSet {
Options {
signature = MD5
}
File = "/var/lib/bareos/bareos.sql" # database dump
File = "/usr/local/etc/bareos" # configuration
File = "@working_dir@/@db_name@.sql" # database dump
File = "@confdir@" # configuration
}
}
Expand Up @@ -5,7 +5,7 @@ FileSet {
Options {
Signature = MD5 # calculate md5 checksum per file
}
#File = "/usr/local/sbin"
File=</file-list
#File = "@sbindir@"
File=<@tmpdir@/file-list
}
}
@@ -0,0 +1,20 @@
Job {
Name = "BackupCatalog"
Description = "Backup the catalog database (after the nightly save)"
JobDefs = "DefaultJob"
Level = Full
FileSet="Catalog"

# This creates an ASCII copy of the catalog
# Arguments to make_catalog_backup.pl are:
# make_catalog_backup.pl <catalog-name>
RunBeforeJob = "@scriptdir@/make_catalog_backup.pl MyCatalog"

# This deletes the copy of the catalog
RunAfterJob = "@scriptdir@/delete_catalog_backup"

# This sends the bootstrap via mail for disaster recovery.
# Should be sent to another system, please change recipient accordingly
Write Bootstrap = "|@bindir@/bsmtp -h @smtp_host@ -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" @job_email@" # (#01)
Priority = 11 # run after main backup
}
@@ -0,0 +1,11 @@
Job {
Name = "RestoreFiles"
Description = "Standard Restore template. Only one such job is needed for all standard Jobs/Clients/Storage ..."
Type = Restore
Client = bareos-fd
FileSet = SelfTest
Storage = File
Pool = Incremental
Messages = Standard
Where = @tmp@/bareos-restores
}
@@ -0,0 +1,5 @@
Job {
Name = "backup-bareos-fd"
JobDefs = "DefaultJob"
Client = "bareos-fd"
}
@@ -0,0 +1,15 @@
JobDefs {
Name = "DefaultJob"
Type = Backup
Level = Incremental
Client = bareos-fd
FileSet = "SelfTest"
Storage = File
Messages = Standard
Pool = Incremental
Priority = 10
Write Bootstrap = "@working_dir@/%c.bsr"
Full Backup Pool = Full # write Full Backups into "Full" Pool
Differential Backup Pool = Differential # write Diff Backups into "Differential" Pool
Incremental Backup Pool = Incremental # write Incr Backups into "Incremental" Pool
}
@@ -0,0 +1,7 @@
Messages {
Name = Daemon
Description = "Message delivery for daemon messages (no job)."
console = all, !skipped, !saved, !audit
append = "@logdir@/bareos.log" = all, !skipped, !audit
append = "@logdir@/bareos-audit.log" = audit
}
@@ -0,0 +1,7 @@
Messages {
Name = Standard
Description = "Reasonable message delivery -- send most everything to email address and to the console."
console = all, !skipped, !saved, !audit
append = "@logdir@/bareos.log" = all, !skipped, !saved, !audit
catalog = all, !skipped, !saved, !audit
}

0 comments on commit fd13940

Please sign in to comment.