Skip to content

Commit

Permalink
Merge pull request #422 from bareos/dev/franku/master/TT4200603
Browse files Browse the repository at this point in the history
dev/franku/master/tt4200603
  • Loading branch information
franku committed Feb 21, 2020
2 parents ea49951 + 94d7f72 commit 9af9eb6
Show file tree
Hide file tree
Showing 24 changed files with 368 additions and 58 deletions.
82 changes: 41 additions & 41 deletions core/src/dird/run_conf.cc
Expand Up @@ -136,12 +136,12 @@ static void set_defaults()
{
have_hour = have_mday = have_wday = have_month = have_wom = have_woy = false;
have_at = false;
SetBits(0, 23, res_run->date_time_bitfield.hour);
SetBits(0, 30, res_run->date_time_bitfield.mday);
SetBits(0, 6, res_run->date_time_bitfield.wday);
SetBits(0, 11, res_run->date_time_bitfield.month);
SetBits(0, 4, res_run->date_time_bitfield.wom);
SetBits(0, 53, res_run->date_time_bitfield.woy);
SetBitRange(0, 23, res_run->date_time_bitfield.hour);
SetBitRange(0, 30, res_run->date_time_bitfield.mday);
SetBitRange(0, 6, res_run->date_time_bitfield.wday);
SetBitRange(0, 11, res_run->date_time_bitfield.month);
SetBitRange(0, 4, res_run->date_time_bitfield.wom);
SetBitRange(0, 53, res_run->date_time_bitfield.woy);
}

/**
Expand Down Expand Up @@ -419,35 +419,35 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
continue;
case s_mday: /* Day of month */
if (!have_mday) {
ClearBits(0, 30, res_run->date_time_bitfield.mday);
ClearBitRange(0, 30, res_run->date_time_bitfield.mday);
have_mday = true;
}
SetBit(code, res_run->date_time_bitfield.mday);
break;
case s_month: /* Month of year */
if (!have_month) {
ClearBits(0, 11, res_run->date_time_bitfield.month);
ClearBitRange(0, 11, res_run->date_time_bitfield.month);
have_month = true;
}
SetBit(code, res_run->date_time_bitfield.month);
break;
case s_wday: /* Week day */
if (!have_wday) {
ClearBits(0, 6, res_run->date_time_bitfield.wday);
ClearBitRange(0, 6, res_run->date_time_bitfield.wday);
have_wday = true;
}
SetBit(code, res_run->date_time_bitfield.wday);
break;
case s_wom: /* Week of month 1st, ... */
if (!have_wom) {
ClearBits(0, 4, res_run->date_time_bitfield.wom);
ClearBitRange(0, 4, res_run->date_time_bitfield.wom);
have_wom = true;
}
SetBit(code, res_run->date_time_bitfield.wom);
break;
case s_woy:
if (!have_woy) {
ClearBits(0, 53, res_run->date_time_bitfield.woy);
ClearBitRange(0, 53, res_run->date_time_bitfield.woy);
have_woy = true;
}
SetBit(code, res_run->date_time_bitfield.woy);
Expand All @@ -457,7 +457,7 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
scan_err0(lc, _("Time must be preceded by keyword AT."));
/* NOT REACHED */
}
if (!have_hour) { ClearBits(0, 23, res_run->date_time_bitfield.hour); }
if (!have_hour) { ClearBitRange(0, 23, res_run->date_time_bitfield.hour); }
// Dmsg1(000, "s_time=%s\n", lc->str);
p = strchr(lc->str, ':');
if (!p) {
Expand Down Expand Up @@ -508,7 +508,7 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
case s_last:
res_run->date_time_bitfield.last_week_of_month = true;
if (!have_wom) {
ClearBits(0, 4, res_run->date_time_bitfield.wom);
ClearBitRange(0, 4, res_run->date_time_bitfield.wom);
have_wom = true;
}
break;
Expand All @@ -531,7 +531,7 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
"than modulo."));
}
if (!have_mday) {
ClearBits(0, 30, res_run->date_time_bitfield.mday);
ClearBitRange(0, 30, res_run->date_time_bitfield.mday);
have_mday = true;
}
/*
Expand Down Expand Up @@ -559,7 +559,7 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
"must always be <= than modulo."));
}
if (!have_woy) {
ClearBits(0, 53, res_run->date_time_bitfield.woy);
ClearBitRange(0, 53, res_run->date_time_bitfield.woy);
have_woy = true;
}
/*
Expand Down Expand Up @@ -590,14 +590,14 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
scan_err0(lc, _("Bad day range specification."));
}
if (!have_mday) {
ClearBits(0, 30, res_run->date_time_bitfield.mday);
ClearBitRange(0, 30, res_run->date_time_bitfield.mday);
have_mday = true;
}
if (code < code2) {
SetBits(code, code2, res_run->date_time_bitfield.mday);
SetBitRange(code, code2, res_run->date_time_bitfield.mday);
} else {
SetBits(code, 30, res_run->date_time_bitfield.mday);
SetBits(0, code2, res_run->date_time_bitfield.mday);
SetBitRange(code, 30, res_run->date_time_bitfield.mday);
SetBitRange(0, code2, res_run->date_time_bitfield.mday);
}
} else if (strlen(lc->str) == 3 && strlen(p) == 3 &&
(lc->str[0] == 'w' || lc->str[0] == 'W') &&
Expand All @@ -612,14 +612,14 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
scan_err0(lc, _("Week number out of range (0-53)"));
}
if (!have_woy) {
ClearBits(0, 53, res_run->date_time_bitfield.woy);
ClearBitRange(0, 53, res_run->date_time_bitfield.woy);
have_woy = true;
}
if (code < code2) {
SetBits(code, code2, res_run->date_time_bitfield.woy);
SetBitRange(code, code2, res_run->date_time_bitfield.woy);
} else {
SetBits(code, 53, res_run->date_time_bitfield.woy);
SetBits(0, code2, res_run->date_time_bitfield.woy);
SetBitRange(code, 53, res_run->date_time_bitfield.woy);
SetBitRange(0, code2, res_run->date_time_bitfield.woy);
}
} else {
/*
Expand Down Expand Up @@ -658,63 +658,63 @@ void StoreRun(LEX* lc, ResourceItem* item, int index, int pass)
}
if (state == s_wday) {
if (!have_wday) {
ClearBits(0, 6, res_run->date_time_bitfield.wday);
ClearBitRange(0, 6, res_run->date_time_bitfield.wday);
have_wday = true;
}
if (code < code2) {
SetBits(code, code2, res_run->date_time_bitfield.wday);
SetBitRange(code, code2, res_run->date_time_bitfield.wday);
} else {
SetBits(code, 6, res_run->date_time_bitfield.wday);
SetBits(0, code2, res_run->date_time_bitfield.wday);
SetBitRange(code, 6, res_run->date_time_bitfield.wday);
SetBitRange(0, code2, res_run->date_time_bitfield.wday);
}
} else if (state == s_month) {
if (!have_month) {
ClearBits(0, 11, res_run->date_time_bitfield.month);
ClearBitRange(0, 11, res_run->date_time_bitfield.month);
have_month = true;
}
if (code < code2) {
SetBits(code, code2, res_run->date_time_bitfield.month);
SetBitRange(code, code2, res_run->date_time_bitfield.month);
} else {
/*
* This is a bit odd, but we accept it anyway
*/
SetBits(code, 11, res_run->date_time_bitfield.month);
SetBits(0, code2, res_run->date_time_bitfield.month);
SetBitRange(code, 11, res_run->date_time_bitfield.month);
SetBitRange(0, code2, res_run->date_time_bitfield.month);
}
} else {
/*
* Must be position
*/
if (!have_wom) {
ClearBits(0, 4, res_run->date_time_bitfield.wom);
ClearBitRange(0, 4, res_run->date_time_bitfield.wom);
have_wom = true;
}
if (code < code2) {
SetBits(code, code2, res_run->date_time_bitfield.wom);
SetBitRange(code, code2, res_run->date_time_bitfield.wom);
} else {
SetBits(code, 4, res_run->date_time_bitfield.wom);
SetBits(0, code2, res_run->date_time_bitfield.wom);
SetBitRange(code, 4, res_run->date_time_bitfield.wom);
SetBitRange(0, code2, res_run->date_time_bitfield.wom);
}
}
}
break;
case s_hourly:
have_hour = true;
SetBits(0, 23, res_run->date_time_bitfield.hour);
SetBitRange(0, 23, res_run->date_time_bitfield.hour);
break;
case s_weekly:
have_mday = have_wom = have_woy = true;
SetBits(0, 30, res_run->date_time_bitfield.mday);
SetBits(0, 4, res_run->date_time_bitfield.wom);
SetBits(0, 53, res_run->date_time_bitfield.woy);
SetBitRange(0, 30, res_run->date_time_bitfield.mday);
SetBitRange(0, 4, res_run->date_time_bitfield.wom);
SetBitRange(0, 53, res_run->date_time_bitfield.woy);
break;
case s_daily:
have_mday = true;
SetBits(0, 6, res_run->date_time_bitfield.wday);
SetBitRange(0, 6, res_run->date_time_bitfield.wday);
break;
case s_monthly:
have_month = true;
SetBits(0, 11, res_run->date_time_bitfield.month);
SetBitRange(0, 11, res_run->date_time_bitfield.month);
break;
default:
scan_err0(lc, _("Unexpected run state\n"));
Expand Down
4 changes: 2 additions & 2 deletions core/src/filed/accurate.h
Expand Up @@ -94,9 +94,9 @@ class BareosAccurateFilelist {
ClearBit(payload->filenr, seen_bitmap_);
}

void MarkAllFilesAsSeen() { SetBits(0, filenr_ - 1, seen_bitmap_); }
void MarkAllFilesAsSeen() { SetBitRange(0, filenr_ - 1, seen_bitmap_); }

void UnmarkAllFilesAsSeen() { ClearBits(0, filenr_ - 1, seen_bitmap_); }
void UnmarkAllFilesAsSeen() { ClearBitRange(0, filenr_ - 1, seen_bitmap_); }
};

/*
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/bits.h
Expand Up @@ -58,7 +58,7 @@
/*
* Set range of bits
*/
#define SetBits(f, l, var) \
#define SetBitRange(f, l, var) \
{ \
int bit; \
for (bit = (f); bit <= (l); bit++) SetBit(bit, (var)); \
Expand All @@ -67,7 +67,7 @@
/*
* Clear range of bits
*/
#define ClearBits(f, l, var) \
#define ClearBitRange(f, l, var) \
{ \
int bit; \
for (bit = (f); bit <= (l); bit++) ClearBit(bit, (var)); \
Expand Down
@@ -0,0 +1,8 @@
Catalog {
Name = MyCatalog
#dbdriver = "postgresql"
dbdriver = "XXX_REPLACE_WITH_DATABASE_DRIVER_XXX"
dbname = "regress_backup_bareos_test"
dbuser = "regress"
dbpassword = ""
}
@@ -0,0 +1,31 @@
Client {
Name = bareos-fd
Description = "Client resource of the Director itself."
Address = localhost
Password = "fd_password" # password for FileDaemon
FD PORT = 42002
}

Client {
Name = bareos-fd-duplicate-interface
Description = "Client resource with identical network interface for setdebug testing"
Address = localhost
Password = "fd_password" # password for FileDaemon
FD PORT = 42002
}

Client {
Name = bareos-fd2
Description = "Client for setdebug testing."
Address = 192.168.101.1
Password = "fd_password" # password for FileDaemon
FD PORT = 42002
}

Client {
Name = bareos-fd3
Description = "Client for setdebug testing."
Address = 192.168.101.1
Password = "fd_password" # password for FileDaemon
FD PORT = 42003
}
@@ -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 = "/tmp/scripts/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 = /tmp/core/src/cats

# 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 = "/tmp/plugindir"
# Plugin Names = ""
Working Directory = "/tmp/tests/backup-bareos-test/working"
Pid Directory = "/tmp/piddir"
DirPort = 42001
}
@@ -0,0 +1,11 @@
FileSet {
Name = "Catalog"
Description = "Backup the catalog dump and Bareos configuration files."
Include {
Options {
signature = MD5
}
File = "/tmp/tests/backup-bareos-test/working/regress_backup_bareos_test.sql" # database dump
File = "/tmp/tests/backup-bareos-test/etc/bareos" # configuration
}
}
@@ -0,0 +1,31 @@
FileSet {
Name = "LinuxAll"
Description = "Backup all regular filesystems, determined by filesystem type."
Include {
Options {
Signature = MD5 # calculate md5 checksum per file
One FS = No # change into other filessytems
FS Type = btrfs
FS Type = ext2 # filesystems of given types will be backed up
FS Type = ext3 # others will be ignored
FS Type = ext4
FS Type = reiserfs
FS Type = jfs
FS Type = xfs
FS Type = zfs
}
File = /
}
# Things that usually have to be excluded
# You have to exclude /tmp/tests/backup-bareos-test/storage
# on your bareos server
Exclude {
File = /tmp/tests/backup-bareos-test/working
File = /tmp/tests/backup-bareos-test/storage
File = /proc
File = /tmp
File = /var/tmp
File = /.journal
File = /.fsck
}
}
@@ -0,0 +1,11 @@
FileSet {
Name = "SelfTest"
Description = "fileset just to backup some files for selftest"
Include {
Options {
Signature = MD5 # calculate md5 checksum per file
}
#File = "/tmp/sbin"
File=</tmp/tests/backup-bareos-test/tmp/file-list
}
}
@@ -0,0 +1,17 @@
FileSet {
Name = "Windows All Drives"
Enable VSS = yes
Include {
Options {
Signature = MD5
Drive Type = fixed
IgnoreCase = yes
WildFile = "[A-Z]:/pagefile.sys"
WildDir = "[A-Z]:/RECYCLER"
WildDir = "[A-Z]:/$RECYCLE.BIN"
WildDir = "[A-Z]:/System Volume Information"
Exclude = yes
}
File = /
}
}

0 comments on commit 9af9eb6

Please sign in to comment.