57 lines
2.3 KiB
Diff
57 lines
2.3 KiB
Diff
From deb3b14a69a31e3c61dc65ba2045637da8f52cf7 Mon Sep 17 00:00:00 2001
|
|
From: progier389 <progier@redhat.com>
|
|
Date: Fri, 15 Nov 2024 12:43:30 +0100
|
|
Subject: [PATCH] Issue 6386 - backup/restore broken after db log rotation
|
|
(#6406)
|
|
|
|
Restore does fail if the db log file have rotated since the backup. The reason is that the current log files are not removed mixing old and new log file which confuse the database.
|
|
Solution is to remove all existing log files before copying the backuped files.
|
|
Note: the number of db region should not change and having an extra db file should not be a problem so only the log files must be removed.
|
|
|
|
Issue: #6386
|
|
|
|
Reviewed by: @mreynolds389, @tbordaz (Thanks!)
|
|
|
|
(cherry picked from commit a48be7b2b389a336e3f48a775e466c71f2eb2b31)
|
|
(cherry picked from commit 0c8829bf43a6b3c413618377e1fbd574cf818f32)
|
|
---
|
|
.../slapd/back-ldbm/db-bdb/bdb_layer.c | 22 +++++++++++++++++++
|
|
1 file changed, 22 insertions(+)
|
|
|
|
diff --git a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
index d2e1331b2..44f25098f 100644
|
|
--- a/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
+++ b/ldap/servers/slapd/back-ldbm/db-bdb/bdb_layer.c
|
|
@@ -5591,6 +5591,28 @@ bdb_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task)
|
|
/* Otherwise use the src_dir from the caller */
|
|
real_src_dir = src_dir;
|
|
|
|
+ /* Lets remove existing log files before copying the new ones (See issue #6386) */
|
|
+ prefix = BDB_CONFIG(li)->bdb_log_directory;
|
|
+ if (prefix == NULL) {
|
|
+ prefix = home_dir;
|
|
+ }
|
|
+ dirhandle = PR_OpenDir(prefix);
|
|
+ if (NULL != dirhandle) {
|
|
+ while (NULL !=
|
|
+ (direntry = PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT))) {
|
|
+ if (NULL == direntry->name) {
|
|
+ /* NSPR doesn't behave like the docs say it should */
|
|
+ break;
|
|
+ }
|
|
+ if (bdb_is_logfilename(direntry->name)) {
|
|
+ PR_snprintf(filename1, sizeof(filename2), "%s/%s",
|
|
+ prefix, direntry->name);
|
|
+ unlink(filename1);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ PR_CloseDir(dirhandle);
|
|
+
|
|
/* We copy the files over from the staging area */
|
|
/* We want to treat the logfiles specially: if there's
|
|
* a log file directory configured, copy the logfiles there
|
|
--
|
|
2.48.1
|
|
|