Skip to content

Commit

Permalink
Merge pull request #1152
Browse files Browse the repository at this point in the history
cats: make `bvfs_update` take archive jobs into consideration
  • Loading branch information
pstorz committed Apr 21, 2022
2 parents 5cbc573 + f8dd07b commit 8175491
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -48,6 +48,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- webui: get volume and pool params from query instead of route [PR #1139]
- FreeBSD packages: add missing ddl/update 2171_2192 and 2192_2210 files [PR #1147]
- Fix director connects to client while `Connection From Director To Client` is disabled. [PR #1099]
- cats: make `.bvfs_update` and `.bvfs_versions` take archive jobs into consideration [PR #1152]

### Changed
- contrib: rename Python modules to satisfy PEP8 [PR #768]
Expand Down
6 changes: 3 additions & 3 deletions core/src/cats/bvfs.cc
Expand Up @@ -277,7 +277,7 @@ void BareosDb::BvfsUpdateCache(JobControlRecord* jcr)
Mmsg(cmd,
"SELECT JobId from Job "
"WHERE HasCache = 0 "
"AND Type IN ('B') AND JobStatus IN ('T', 'W', 'f', 'A') "
"AND Type IN ('B','A','a') AND JobStatus IN ('T', 'W', 'f', 'A') "
"ORDER BY JobId");
SqlQuery(cmd, DbListHandler, &jobids_list);

Expand Down Expand Up @@ -524,9 +524,9 @@ void Bvfs::GetAllFileVersions(DBId_t pathid,
client);

if (see_copies) {
Mmsg(filter, " AND Job.Type IN ('C', 'B') ");
Mmsg(filter, " AND Job.Type IN ('C', 'B', 'A', 'a') ");
} else {
Mmsg(filter, " AND Job.Type = 'B' ");
Mmsg(filter, " AND Job.Type IN ('B', 'A', 'a') ");
}

db->EscapeString(jcr, fname_esc, fname, strlen(fname));
Expand Down
@@ -0,0 +1,17 @@
Job {
Name = "VirtualLongtermFull"
Client = bareos-fd
FileSet = SelfTest
Type = Backup
Level = VirtualFull
Pool = AI-Consolidated
Messages = Standard

Priority = 13 # run after Consolidate
Run Script {
console = "update jobid=%i jobtype=A"
Runs When = After
Runs On Client = No
Runs On Failure = No
}
}
Expand Up @@ -8,4 +8,5 @@ Pool {
Label Format = "AI-Consolidated-"
Volume Use Duration = 23h
Storage = File
Next Pool = AI-Longterm
}
@@ -0,0 +1,11 @@
Pool {
Name = AI-Longterm
Pool Type = Backup
Recycle = yes # Bareos can automatically recycle Volumes
Auto Prune = yes # Prune expired volumes
Volume Retention = 1 days # How long should jobs be kept?
Maximum Volume Bytes = 1G # Limit Volume size to something reasonable
Label Format = "AI-Longterm-"
Volume Use Duration = 23h
Storage = File
}
44 changes: 40 additions & 4 deletions systemtests/tests/ai-consolidate-ignore-duplicate-job/testrunner
Expand Up @@ -33,6 +33,8 @@ setup_data

start_test

start_bareos

cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
Expand All @@ -51,7 +53,7 @@ run job=$JobName level=Incremental yes
wait
messages
END_OF_DATA
run_bareos "$@"
run_bconsole

cat <<END_OF_DATA >$tmp/bconcmds
@$out $tmp/log1.out
Expand All @@ -66,7 +68,7 @@ messages
wait
quit
END_OF_DATA
run_bareos "$@"
run_bconsole

# Consolidating zero-file incremental backups

Expand All @@ -86,7 +88,7 @@ wait
messages
quit
END_OF_DATA
run_bareos "$@"
run_bconsole

# Consolidating a zero-file job in the middle of incremental backups

Expand Down Expand Up @@ -116,7 +118,33 @@ END_OF_DATA

run_bconsole

stop_bareos
cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
wait
@$out $tmp/virtualfull.out
run job=VirtualLongtermFull yes
wait
@exec "sh -c 'touch ${tmp}/data/weird-files/file-13'"
run job=$JobName level=Incremental yes
wait
@exec "sh -c 'touch ${tmp}/data/weird-files/file-14'"
run job=$JobName level=Incremental yes
wait
@exec "sh -c 'touch ${tmp}/data/weird-files/file-15'"
run job=$JobName level=Incremental yes
wait
messages
.bvfs_lsdirs jobid=16 path=
.bvfs_update
.bvfs_lsdirs jobid=16 path=
.bvfs_versions jobid=16 path=${tmp}/data/weird-files/ client=bareos-fd fname=normalfile
wait
messages
quit
END_OF_DATA

run_bconsole

check_job_canceled

Expand All @@ -136,4 +164,12 @@ expect_grep "purged JobIds 6,4,11 as they were consolidated into Job 15" \
"$tmp"/log3.out \
"consolidation of expected jobs did not happen."

expect_grep "0 0 A A A A A A A A A A A A A A /" \
"$tmp"/virtualfull.out \
"bvfs_update did not take into consideration VirtualFull Archive."

expect_grep "43xzp14Dk2Gvm+cKgszDNQ AI-Longterm" \
"$tmp"/virtualfull.out \
".bvfs_versions did not find a file backup up by a VirtualFull Archive."

end_test

0 comments on commit 8175491

Please sign in to comment.