Skip to content

Commit

Permalink
core: set hardlinks=no as default
Browse files Browse the repository at this point in the history
When you have a file with multiple hardlinks and the first hardlink
encountered gets excluded, then no actual file data is send but the
backup is still finishes without errors.

On restore you will get an error.

- hardlink fix camelcase output in dir_conf.cc
- Add HardLink = No for config-dump and gluster systemtest

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
  • Loading branch information
bruno-at-bareos committed Aug 7, 2023
1 parent 9209b25 commit 6b3d031
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 65 deletions.
2 changes: 1 addition & 1 deletion core/src/dird/dird_conf.cc
Expand Up @@ -1864,7 +1864,7 @@ void FilesetResource::PrintConfigIncludeExcludeOptions(
send.KeyBool("Recurse", false);
break;
case 'H': /* no hard link handling */
send.KeyBool("Hardlinks", false);
send.KeyBool("HardLinks", false);
break;
case 'i':
send.KeyBool("IgnoreCase", true);
Expand Down
17 changes: 8 additions & 9 deletions core/src/dird/inc_conf.cc
Expand Up @@ -231,10 +231,8 @@ static IncludeExcludeItem* res_incexe;

/* clang-format off */

/*
* new Include/Exclude items
* name handler value code flags default_value
*/
/* new Include/Exclude items
* name handler value code flags default_value */
ResourceItem newinc_items[] = {
{ "File", CFG_TYPE_FNAME, 0, nullptr, 0, 0, NULL, NULL, NULL },
{ "Plugin", CFG_TYPE_PLUGINNAME, 0, nullptr, 0, 0, NULL, NULL, NULL },
Expand All @@ -243,10 +241,8 @@ ResourceItem newinc_items[] = {
{ NULL, 0, 0, nullptr, 0, 0, NULL, NULL, NULL }
};

/*
* Items that are valid in an Options resource
* name handler value code flags default_value
*/
/* Items that are valid in an Options resource
* name handler value code flags default_value */
ResourceItem options_items[] = {
{ "Compression", CFG_TYPE_OPTION, 0, nullptr, 0, 0, NULL, NULL, NULL },
{ "Signature", CFG_TYPE_OPTION, 0, nullptr, 0, 0, NULL, NULL, NULL },
Expand Down Expand Up @@ -295,7 +291,10 @@ ResourceItem options_items[] = {

struct OptionsDefaultValues {
std::map<int, options_default_value_s> option_default_values
= {{INC_KW_ACL, {false, "A"}}, {INC_KW_XATTR, {false, "X"}}};
= {{INC_KW_ACL, {false, "A"}},
{INC_KW_HARDLINK, {false, "H"}},
{INC_KW_XATTR, {false, "X"}}
};
};

// determine used compression algorithms
Expand Down
22 changes: 12 additions & 10 deletions docs/manuals/source/Configuration/Director.rst
Expand Up @@ -1151,18 +1151,20 @@ The directives within an Options resource may be one of the following:
.. config:option:: dir/fileset/include/options/HardLinks
:type: yes|no
:default: yes
:default: no


When enabled (default), this directive will cause hard links to be
backed up. However, the File daemon keeps track of hard linked files and
will backup the data only once. The process of keeping track of the
hard links can be quite expensive if you have lots of them (tens of
thousands or more). This doesn't occur on normal Unix systems, but if
you use a program like BackupPC, it can create hundreds of thousands, or
even millions of hard links. Backups become very long and the File daemon
will consume a lot of CPU power checking hard links. In such a case,
set :config:option:`dir/fileset/include/options/HardLinks = no`
When enabled, this directive will cause hard links to be backed up.
However, the File daemon keeps track of hard linked files and
will backup the data only once. When you have a file with multiple hardlinks
and the first hardlink encountered gets excluded, then no actual file data is
send but the backup is still finishes without errors, which normally would create
an error on restore. In such a case the hardlink information will be dropped and
not restored.
Also be aware that the process of keeping track of the hard links can be quite
expensive if you have lots of them (tens of thousands or more). Backups become
very long and the File daemon will consume a lot of CPU power checking hard links.
In such a case, set :config:option:`dir/fileset/include/options/HardLinks = no`
and hard links will not be backed up. Note, using
this option will most likely backup more data and on a restore the file
system will not be restored identically to the original.
Expand Down
102 changes: 57 additions & 45 deletions systemtests/tests/config-dump/etc/bareos/bareos-dir-full.conf.in
Expand Up @@ -255,7 +255,7 @@ JobDefs {

JobDefs {
Name = "JobDefWithRunScripts"
# Description =
# Description =
Type = Backup
# Protocol = Native
# BackupFormat = "Native"
Expand All @@ -274,15 +274,15 @@ JobDefs {
# JobToVerify = ""
# Catalog = ""
# JobDefs = ""
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
WriteBootstrap = "/var/lib/bareos/%c.bsr"
# WriteVerifyList =
# WriteVerifyList =
# Replace = Always
# MaximumBandwidth = 0
# MaxRunSchedTime = 0
Expand All @@ -308,11 +308,11 @@ JobDefs {
# PreferMountedVolumes = Yes
# MaximumConcurrentJobs = 1
# RescheduleOnError = No
# RescheduleInterval = 30 minutes
# RescheduleInterval = 30 minutes
# RescheduleTimes = 5
# Priority = 10
# AllowMixedPriority = No
# SelectionPattern =
# SelectionPattern =
ClientRunBeforeJob = "/tmp/JobDefClientRunBeforeJob1.sh"
ClientRunBeforeJob = "/tmp/JobDefClientRunBeforeJob2.sh"
ClientRunAfterJob = "/tmp/JobDefClientRunAfterJob1"
Expand Down Expand Up @@ -345,10 +345,10 @@ JobDefs {
# CancelRunningDuplicates = No
# SaveFileHistory = Yes
# FileHistorySize = 9 m 549 k 640
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# MaxConcurrentCopies = 100
# AlwaysIncremental = No
# AlwaysIncrementalJobRetention = 0
Expand Down Expand Up @@ -1035,7 +1035,7 @@ Job {

Job {
Name = "job-only-with-jobdefs-runscripts"
# Description =
# Description =
# Type = Backup
# Protocol = Native
# BackupFormat = "Native"
Expand All @@ -1054,15 +1054,15 @@ Job {
# JobToVerify = ""
# Catalog = ""
JobDefs = "JobDefWithRunScripts"
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
# WriteBootstrap = "/var/lib/bareos/%c.bsr"
# WriteVerifyList =
# WriteVerifyList =
# Replace = Always
# MaximumBandwidth = 0
# MaxRunSchedTime = 0
Expand All @@ -1088,11 +1088,11 @@ Job {
# PreferMountedVolumes = Yes
# MaximumConcurrentJobs = 1
# RescheduleOnError = No
# RescheduleInterval = 30 minutes
# RescheduleInterval = 30 minutes
# RescheduleTimes = 5
# Priority = 10
# AllowMixedPriority = No
# SelectionPattern =
# SelectionPattern =
# ClientRunBeforeJob = "/tmp/JobDefClientRunBeforeJob1.sh"
# ClientRunBeforeJob = "/tmp/JobDefClientRunBeforeJob2.sh"
# ClientRunAfterJob = "/tmp/JobDefClientRunAfterJob1"
Expand Down Expand Up @@ -1125,10 +1125,10 @@ Job {
# CancelRunningDuplicates = No
# SaveFileHistory = Yes
# FileHistorySize = 9 m 549 k 640
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# MaxConcurrentCopies = 100
# AlwaysIncremental = No
# AlwaysIncrementalJobRetention = 0
Expand All @@ -1140,7 +1140,7 @@ Job {

Job {
Name = "job-with-jobdefs-runscripts"
# Description =
# Description =
# Type = Backup
# Protocol = Native
# BackupFormat = "Native"
Expand All @@ -1159,15 +1159,15 @@ Job {
# JobToVerify = ""
# Catalog = ""
JobDefs = "JobDefWithRunScripts"
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
# Run =
# Where =
# RegexWhere =
# StripPrefix =
# AddPrefix =
# AddSuffix =
# Bootstrap =
# WriteBootstrap = "/var/lib/bareos/%c.bsr"
# WriteVerifyList =
# WriteVerifyList =
# Replace = Always
# MaximumBandwidth = 0
# MaxRunSchedTime = 0
Expand All @@ -1193,11 +1193,11 @@ Job {
# PreferMountedVolumes = Yes
# MaximumConcurrentJobs = 1
# RescheduleOnError = No
# RescheduleInterval = 30 minutes
# RescheduleInterval = 30 minutes
# RescheduleTimes = 5
# Priority = 10
# AllowMixedPriority = No
# SelectionPattern =
# SelectionPattern =
RunScript {
Command = "/tmp/RunScriptCommandBeforeOnClient.sh"
RunsWhen = "before"
Expand Down Expand Up @@ -1246,10 +1246,10 @@ Job {
# CancelRunningDuplicates = No
# SaveFileHistory = Yes
# FileHistorySize = 9 m 549 k 640
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# FdPluginOptions =
# SdPluginOptions =
# DirPluginOptions =
# Base =
# MaxConcurrentCopies = 100
# AlwaysIncremental = No
# AlwaysIncrementalJobRetention = 0
Expand Down Expand Up @@ -1341,6 +1341,7 @@ FileSet {
Exclude = Yes
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
WildDir = "[A-Z]:/RECYCLER"
WildDir = "[A-Z]:/$RECYCLE.BIN"
WildDir = "[A-Z]:/System Volume Information"
Expand All @@ -1359,6 +1360,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/usr/sbin"
}
Expand All @@ -1373,6 +1375,7 @@ FileSet {
OneFS = No
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
FsType = "btrfs"
FsType = "ext2"
FsType = "ext3"
Expand Down Expand Up @@ -1404,6 +1407,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/var/lib/bareos/bareos.sql"
File = "/etc/bareos"
Expand All @@ -1418,6 +1422,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir"
File = "\<includefile-server"
Expand All @@ -1434,13 +1439,15 @@ FileSet {
Options {
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir11"
}
Include {
Options {
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir22"
}
Expand All @@ -1454,6 +1461,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
Wild = "/tmp/data/*1/*"
WildDir = "/tmp/data/*1"
}
Expand All @@ -1462,6 +1470,7 @@ FileSet {
Compression = "GZIP3"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
Wild = "/tmp/data/*2/*"
Wild = "/tmp/data/*22/*"
WildDir = "/tmp/data/*2"
Expand All @@ -1473,6 +1482,7 @@ FileSet {
Options {
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir22"
}
Expand All @@ -1486,6 +1496,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir11"
File = "/tmp/dir12"
Expand All @@ -1499,6 +1510,7 @@ FileSet {
Signature = "MD5"
AclSupport = Yes
XattrSupport = Yes
HardLinks = No
}
File = "/tmp/dir21"
File = "/tmp/dir22"
Expand Down
Expand Up @@ -4,6 +4,7 @@ FileSet {
Include {
Options {
Signature = XXH128
HardLinks = yes
}
File = "@working_dir@/@db_name@.sql" # database dump
File = "@confdir@" # configuration
Expand Down
Expand Up @@ -4,6 +4,7 @@ FileSet {
Include {
Options {
Signature = XXH128
Hardlinks = yes
}
Plugin = "gfapi:volume=gluster\\://@gfapi_fd_host@/@gfapi_fd_testvolume@:"`
}
Expand Down
Expand Up @@ -4,6 +4,7 @@ FileSet {
Include {
Options {
Signature = XXH128
HardLinks = yes
}
File = "@working_dir@/@db_name@.sql" # database dump
File = "@confdir@" # configuration
Expand Down
Expand Up @@ -4,6 +4,7 @@ FileSet {
Include {
Options {
Signature = XXH128
Hardlinks = yes
}
#File = "@sbindir@"
File=<@tmpdir@/file-list
Expand Down

0 comments on commit 6b3d031

Please sign in to comment.