[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Fri Aug 30 00:09:02 UTC 2024


The branch, master has been updated
       via  574f2c3ed8d ctdb-tests: Add persistent TDB backup tests
       via  05da9001b9e ctdb-scripts: Add support for backing up persistent TDBs
       via  82250f36294 ctdb-scripts: Move database handling to its own event script
       via  9c354e358e5 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
       via  b4c7a4f7f0e ctdb-scripts: Remove unused variable NFS_HOSTNAME
       via  ece6153038b ctdb-scripts: Use nfs-utils' sm-notify instead of CTDB's smnotify
       via  d89506449fc ctdb-failover: Add ctdb_smnotify_helper
      from  e2c8f718cad s4:torture/smb2: better error handling in create.c

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 574f2c3ed8dde01610ad9a36d57cc30d6d0008ed
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed Apr 10 16:55:01 2024 +1000

    ctdb-tests: Add persistent TDB backup tests
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Aug 30 00:08:41 UTC 2024 on atb-devel-224

commit 05da9001b9edc954c009be19a881626b2a763146
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Fri Apr 5 17:12:40 2024 +1100

    ctdb-scripts: Add support for backing up persistent TDBs
    
    Signed-off-by: Vinit Agnihotri <vagnihotri at ddn.com>
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 82250f3629424385f21d18dc65e68eb2866d3d73
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Apr 8 11:15:24 2024 +1000

    ctdb-scripts: Move database handling to its own event script
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9c354e358e59da2e0b5ad1d13d5b411458476ab3
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Mon Apr 8 11:08:33 2024 +1000

    ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
    
    Best reviewed with "git show -w".
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b4c7a4f7f0e40079b7e5f13b97e33148ec995376
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed May 1 10:22:05 2024 +1000

    ctdb-scripts: Remove unused variable NFS_HOSTNAME
    
    This was passed to CTDB's old smnotify.  This has been replaced by use
    of nfs-utils' sm-notify, which doesn't need this.
    
    In test, a fake NFS_HOSTNAME is still needed.  Real sm-notify will get
    it from a reverse host lookup of the IP address.
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ece6153038b7556877ae82c1c0843175d743eff7
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 3 15:44:08 2017 +1100

    ctdb-scripts: Use nfs-utils' sm-notify instead of CTDB's smnotify
    
    CTDB's smnotify does not support IPv6 and is difficult to maintain.
    
    So, create directories of files and pass them to NFS util's sm-notify.
    
    There is an implied change here, because NFS utils sm-notify stopped
    sending IP addresses as mon_name back in 2010:
    
      http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=900df0e7c0b9006d72d8459b30dc2cd69ce495a5
    
    This will change advice given in the wiki to use a hostname for the
    cluster with round-robin DNS, since this is what is best supported.
    
    Another behavioural change is that sm-notify only sends "up"
    notifications with an odd state.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d89506449fc01debc4013de9afe7f5784019806f
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Wed May 10 12:21:07 2023 +1000

    ctdb-failover: Add ctdb_smnotify_helper
    
    statd callout will shortly be updated to use NFS utils' sm-notify.
    This tiny helper will be used to create on-disk state files used by
    sm-notify.  These state files contain endian-specific fields, so
    better to write a simple C implementation than to do crazy things in a
    shell script (or call out to Python).
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/.gitignore                                    |   3 -
 ctdb/config/ctdb-backup-persistent-tdbs.sh         | 123 ++++++++++++++++
 ctdb/config/events/legacy/00.ctdb.script           | 107 +-------------
 ctdb/config/events/legacy/95.database.script       | 156 +++++++++++++++++++++
 ctdb/doc/ctdb-script.options.5.xml                 |  57 +++++++-
 ctdb/doc/ctdb.1.xml                                |  60 ++++----
 ctdb/doc/examples/ctdb.spec.in                     |   2 +
 ctdb/failover/smnotify_helper.c                    |  81 +++++++++++
 ...00.ctdb.init.001.sh => 95.database.init.001.sh} |   0
 ...00.ctdb.init.002.sh => 95.database.init.002.sh} |   0
 ...00.ctdb.init.003.sh => 95.database.init.003.sh} |   0
 ...00.ctdb.init.004.sh => 95.database.init.004.sh} |   0
 ...00.ctdb.init.005.sh => 95.database.init.005.sh} |   0
 ...00.ctdb.init.006.sh => 95.database.init.006.sh} |   0
 ...00.ctdb.init.007.sh => 95.database.init.007.sh} |   0
 ...00.ctdb.init.008.sh => 95.database.init.008.sh} |   0
 ...00.ctdb.init.009.sh => 95.database.init.009.sh} |   0
 ...d.monitor.101.sh => 95.database.monitor.001.sh} |   3 +-
 .../UNIT/eventscripts/95.database.monitor.002.sh   |  31 ++++
 .../UNIT/eventscripts/95.database.monitor.003.sh   |  40 ++++++
 .../UNIT/eventscripts/95.database.monitor.004.sh   |  40 ++++++
 .../UNIT/eventscripts/95.database.monitor.005.sh   |  26 ++++
 .../UNIT/eventscripts/95.database.monitor.006.sh   |  36 +++++
 ctdb/tests/UNIT/eventscripts/etc/sysconfig/nfs     |   2 -
 .../scripts/{00.ctdb.sh => 95.database.sh}         |   0
 ctdb/tests/UNIT/eventscripts/scripts/local.sh      |   7 +
 .../UNIT/eventscripts/scripts/statd-callout.sh     |  16 ++-
 ctdb/tests/UNIT/eventscripts/stubs/ctdb            |  93 +++++++++++-
 .../UNIT/eventscripts/stubs/ctdb_smnotify_helper   |  44 ++++++
 ctdb/tests/UNIT/eventscripts/stubs/sm-notify       |  76 ++++++++++
 ctdb/tests/UNIT/eventscripts/stubs/smnotify        |  65 ---------
 ctdb/tools/statd_callout_helper                    | 107 +++++++-------
 ctdb/utils/smnotify/smnotify.c                     | 151 --------------------
 ctdb/utils/smnotify/smnotify.x                     |  21 ---
 ctdb/wscript                                       |  27 +---
 35 files changed, 908 insertions(+), 466 deletions(-)
 create mode 100755 ctdb/config/ctdb-backup-persistent-tdbs.sh
 create mode 100755 ctdb/config/events/legacy/95.database.script
 create mode 100644 ctdb/failover/smnotify_helper.c
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.001.sh => 95.database.init.001.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.002.sh => 95.database.init.002.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.003.sh => 95.database.init.003.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.004.sh => 95.database.init.004.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.005.sh => 95.database.init.005.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.006.sh => 95.database.init.006.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.007.sh => 95.database.init.007.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.008.sh => 95.database.init.008.sh} (100%)
 rename ctdb/tests/UNIT/eventscripts/{00.ctdb.init.009.sh => 95.database.init.009.sh} (100%)
 copy ctdb/tests/UNIT/eventscripts/{49.winbind.monitor.101.sh => 95.database.monitor.001.sh} (58%)
 create mode 100755 ctdb/tests/UNIT/eventscripts/95.database.monitor.002.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/95.database.monitor.003.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/95.database.monitor.004.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/95.database.monitor.005.sh
 create mode 100755 ctdb/tests/UNIT/eventscripts/95.database.monitor.006.sh
 delete mode 100644 ctdb/tests/UNIT/eventscripts/etc/sysconfig/nfs
 rename ctdb/tests/UNIT/eventscripts/scripts/{00.ctdb.sh => 95.database.sh} (100%)
 create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/ctdb_smnotify_helper
 create mode 100755 ctdb/tests/UNIT/eventscripts/stubs/sm-notify
 delete mode 100755 ctdb/tests/UNIT/eventscripts/stubs/smnotify
 delete mode 100644 ctdb/utils/smnotify/smnotify.c
 delete mode 100644 ctdb/utils/smnotify/smnotify.x


Changeset truncated at 500 lines:

diff --git a/ctdb/.gitignore b/ctdb/.gitignore
index f0534b3afd1..70cf71f3a4d 100644
--- a/ctdb/.gitignore
+++ b/ctdb/.gitignore
@@ -14,9 +14,6 @@ Makefile
 config.h
 config.h.in
 config.log
-utils/smnotify/gen_smnotify.c
-utils/smnotify/gen_xdr.c
-utils/smnotify/smnotify.h
 nodes.txt
 public_addresses.txt
 rec.lock
diff --git a/ctdb/config/ctdb-backup-persistent-tdbs.sh b/ctdb/config/ctdb-backup-persistent-tdbs.sh
new file mode 100755
index 00000000000..9610eefeb38
--- /dev/null
+++ b/ctdb/config/ctdb-backup-persistent-tdbs.sh
@@ -0,0 +1,123 @@
+#!/bin/sh
+
+# Backup persistent CTDB TDBs into the given directory.
+
+# Copyright: DataDirect Networks, 2024
+# Authors: Vinit Agnihotri <vagnihotri at ddn.com>
+#          Martin Schwenke <mschwenke at ddn.com>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+# Options:
+#
+# -l: Only do the backup if this node is the leader node, otherwise
+#     exit with 0.
+#
+# -L <rc>: Only do the backup if this node is the leader node, otherwise
+#     exit with <rc>.
+
+#
+# Option/argument handling
+#
+
+die()
+{
+	echo "ERROR: $1"
+	exit 1
+}
+
+usage()
+{
+	die "usage: $0 [-l | -L <rc> ] <dir>"
+}
+
+leader_only=false
+leader_only_rc=0
+dir=""
+
+while getopts "L:lh?" opt; do
+	case "$opt" in
+	L)
+		leader_only=true
+		leader_only_rc="$OPTARG"
+		;;
+	l)
+		leader_only=true
+		;;
+	\? | h)
+		usage
+		;;
+	esac
+done
+shift $((OPTIND - 1))
+
+if [ $# -ne 1 ]; then
+	usage
+fi
+
+dir="$1"
+
+if [ ! -d "$dir" ]; then
+	die "No such directory ${dir}"
+fi
+
+if $leader_only; then
+	this_node=$(ctdb pnn)
+	leader_node=$(ctdb leader)
+	if [ "$this_node" != "$leader_node" ]; then
+		exit "$leader_only_rc"
+	fi
+fi
+
+#
+# Backups TDBs in timestamped subdirectory
+#
+
+dt=$(date "+%Y%m%d%H%M%S")
+prefix="ctdb-persistent-db-backup-${dt}"
+outdir="${dir}/${prefix}"
+
+# Clean up temporary directory on failure"
+trap 'rm -rf ${outdir}' 0
+
+mkdir -p "$outdir"
+
+if ! db_map=$(ctdb getdbmap -X); then
+	die "Failed to list databases"
+fi
+db_list=$(echo "$db_map" | awk -F '|' '$5 == "1" { print $3 }')
+
+cd "$outdir" || die "Failed to change directory to ${dir}"
+
+for db in $db_list; do
+	if ! ctdb backupdb "$db" "${db}.backup"; then
+		die "Failed to backup ${db}"
+	fi
+done
+
+#
+# Create tarball
+#
+
+cd "$dir" || die "Failed to change directory to ${dir}"
+
+tarball="${prefix}.tgz"
+
+if ! tar -c -z -f "$tarball" "$prefix"; then
+	die "Failed to create tarball"
+fi
+
+echo "Created backup tarball ${dir}/${tarball}"
+
+exit 0
diff --git a/ctdb/config/events/legacy/00.ctdb.script b/ctdb/config/events/legacy/00.ctdb.script
index 292081bbe06..0c73f80c6aa 100755
--- a/ctdb/config/events/legacy/00.ctdb.script
+++ b/ctdb/config/events/legacy/00.ctdb.script
@@ -3,7 +3,7 @@
 # Event script for ctdb-specific setup and other things that don't fit
 # elsewhere.
 
-[ -n "$CTDB_BASE" ] || \
+[ -n "$CTDB_BASE" ] ||
 	CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
 
 . "${CTDB_BASE}/functions"
@@ -12,113 +12,14 @@ load_script_options
 
 ############################################################
 
-# type is commonly supported and more portable than which(1)
-# shellcheck disable=SC2039
-select_tdb_checker ()
-{
-    # Find the best TDB consistency check available.
-    use_tdb_tool_check=false
-    type tdbtool >/dev/null 2>&1 && found_tdbtool=true
-    type tdbdump >/dev/null 2>&1 && found_tdbdump=true
-
-    if $found_tdbtool && echo "help" | tdbtool | grep -q check ; then
-	    use_tdb_tool_check=true
-    elif $found_tdbtool && $found_tdbdump ; then
-	    cat <<EOF
-WARNING: The installed 'tdbtool' does not offer the 'check' subcommand.
- Using 'tdbdump' for database checks.
- Consider updating 'tdbtool' for better checks!
-EOF
-    elif $found_tdbdump ; then
-	cat <<EOF
-WARNING: 'tdbtool' is not available.
- Using 'tdbdump' to check the databases.
- Consider installing a recent 'tdbtool' for better checks!
-EOF
-    else
-	cat <<EOF
-WARNING: Cannot check databases since neither
- 'tdbdump' nor 'tdbtool check' is available.
- Consider installing tdbtool or at least tdbdump!
-EOF
-        return 1
-    fi
-}
-
-check_tdb ()
-{
-    _db="$1"
-
-    if $use_tdb_tool_check ; then
-	# tdbtool always exits with 0  :-(
-	if timeout 10 tdbtool "$_db" check 2>/dev/null |
-	    grep -q "Database integrity is OK" ; then
-	    return 0
-	else
-	    return 1
-	fi
-    else
-	timeout 10 tdbdump "$_db" >/dev/null 2>/dev/null
-	return $?
-    fi
-}
-
-check_persistent_databases ()
-{
-    _dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_VARDIR}/persistent}"
-    [ -d "$_dir" ] || return 0
-
-    for _db in "$_dir/"*.tdb.*[0-9] ; do
-	[ -r "$_db" ] || continue
-	check_tdb "$_db" || \
-	    die "Persistent database $_db is corrupted! CTDB will not start."
-    done
-}
-
-check_non_persistent_databases ()
-{
-    _dir="${CTDB_DBDIR:-${CTDB_VARDIR}}"
-    [ -d "$_dir" ] || return 0
-
-    for _db in "${_dir}/"*.tdb.*[0-9] ; do
-	[ -r "$_db" ] || continue
-	check_tdb "$_db" || {
-	    _backup="${_db}.$(date +'%Y%m%d.%H%M%S').corrupt"
-	    cat <<EOF
-WARNING: database ${_db} is corrupted.
- Moving to backup ${_backup} for later analysis.
-EOF
-	    mv "$_db" "$_backup"
-
-	    # Now remove excess backups
-	    _max="${CTDB_MAX_CORRUPT_DB_BACKUPS:-10}"
-	    _bdb="${_db##*/}" # basename
-	    find "$_dir" -name "${_bdb}.*.corrupt" |
-		    sort -r |
-		    tail -n +$((_max + 1)) |
-		    xargs rm -f
-	}
-    done
-}
-
-############################################################
-
 ctdb_check_args "$@"
 
 case "$1" in
 init)
-        # make sure we have a blank state directory for the scripts to work with
+	# Initialise script directory
 	rm -rf "$CTDB_SCRIPT_VARDIR"
-	mkdir -p "$CTDB_SCRIPT_VARDIR" || \
-	    die "mkdir -p ${CTDB_SCRIPT_VARDIR} - failed - $?" $?
-
-	# Load/cache database options from configuration file
-	ctdb_get_db_options
-
-	if select_tdb_checker ; then
-	    check_persistent_databases || exit $?
-	    check_non_persistent_databases
-	fi
+	mkdir -p "$CTDB_SCRIPT_VARDIR" ||
+		die "mkdir -p ${CTDB_SCRIPT_VARDIR} - failed - $?" $?
 	;;
 esac
 
diff --git a/ctdb/config/events/legacy/95.database.script b/ctdb/config/events/legacy/95.database.script
new file mode 100755
index 00000000000..e2627c6c1d0
--- /dev/null
+++ b/ctdb/config/events/legacy/95.database.script
@@ -0,0 +1,156 @@
+#!/bin/sh
+
+# Event script for ctdb-specific setup and other things that don't fit
+# elsewhere.
+
+[ -n "$CTDB_BASE" ] ||
+	CTDB_BASE=$(d=$(dirname "$0") && cd -P "$d" && dirname "$PWD")
+
+. "${CTDB_BASE}/functions"
+
+load_script_options
+
+############################################################
+
+# type is commonly supported and more portable than which(1)
+# shellcheck disable=SC2039
+select_tdb_checker()
+{
+	# Find the best TDB consistency check available.
+	use_tdb_tool_check=false
+	type tdbtool >/dev/null 2>&1 && found_tdbtool=true
+	type tdbdump >/dev/null 2>&1 && found_tdbdump=true
+
+	if $found_tdbtool && echo "help" | tdbtool | grep -q check; then
+		use_tdb_tool_check=true
+	elif $found_tdbtool && $found_tdbdump; then
+		cat <<EOF
+WARNING: The installed 'tdbtool' does not offer the 'check' subcommand.
+ Using 'tdbdump' for database checks.
+ Consider updating 'tdbtool' for better checks!
+EOF
+	elif $found_tdbdump; then
+		cat <<EOF
+WARNING: 'tdbtool' is not available.
+ Using 'tdbdump' to check the databases.
+ Consider installing a recent 'tdbtool' for better checks!
+EOF
+	else
+		cat <<EOF
+WARNING: Cannot check databases since neither
+ 'tdbdump' nor 'tdbtool check' is available.
+ Consider installing tdbtool or at least tdbdump!
+EOF
+		return 1
+	fi
+}
+
+check_tdb()
+{
+	_db="$1"
+
+	if $use_tdb_tool_check; then
+		# tdbtool always exits with 0  :-(
+		if timeout 10 tdbtool "$_db" check 2>/dev/null |
+			grep -q "Database integrity is OK"; then
+			return 0
+		else
+			return 1
+		fi
+	else
+		timeout 10 tdbdump "$_db" >/dev/null 2>/dev/null
+		return $?
+	fi
+}
+
+check_persistent_databases()
+{
+	_dir="${CTDB_DBDIR_PERSISTENT:-${CTDB_VARDIR}/persistent}"
+	[ -d "$_dir" ] || return 0
+
+	for _db in "$_dir/"*.tdb.*[0-9]; do
+		[ -r "$_db" ] || continue
+		check_tdb "$_db" ||
+			die "Persistent database $_db is corrupted! CTDB will not start."
+	done
+}
+
+check_non_persistent_databases()
+{
+	_dir="${CTDB_DBDIR:-${CTDB_VARDIR}}"
+	[ -d "$_dir" ] || return 0
+
+	for _db in "${_dir}/"*.tdb.*[0-9]; do
+		[ -r "$_db" ] || continue
+		check_tdb "$_db" || {
+			_backup="${_db}.$(date +'%Y%m%d.%H%M%S').corrupt"
+			cat <<EOF
+WARNING: database ${_db} is corrupted.
+ Moving to backup ${_backup} for later analysis.
+EOF
+			mv "$_db" "$_backup"
+
+			# Now remove excess backups
+			_max="${CTDB_MAX_CORRUPT_DB_BACKUPS:-10}"
+			_bdb="${_db##*/}" # basename
+			find "$_dir" -name "${_bdb}.*.corrupt" |
+				sort -r |
+				tail -n +$((_max + 1)) |
+				xargs rm -f
+		}
+	done
+}
+
+maybe_backup_persistent_tdbs()
+{
+	_dir="${CTDB_PERSISTENT_DB_BACKUP_DIR:-}"
+	if [ -z "$_dir" ]; then
+		return 0
+	fi
+
+	if [ ! -d "$_dir" ]; then
+		echo "Creating CTDB_PERSISTENT_DB_BACKUP_DIR=${_dir}"
+		if ! mkdir -p "$_dir"; then
+			die "ERROR: unable to create ${_dir}"
+		fi
+	fi
+
+	# Don't backup if there are backup files from within the past day
+	_out=$(find "$_dir" -type f -mtime -1)
+	if [ -n "$_out" ]; then
+		return 0
+	fi
+
+	# Script will ignore if this isn't leader node, so don't
+	# double-check that here...
+	"${CTDB_BASE}/ctdb-backup-persistent-tdbs.sh" -l "$_dir"
+
+	# Remove backups beyond the limit (default 14)
+	_limit="${CTDB_PERSISTENT_DB_BACKUP_LIMIT:-14}"
+	_offset=$((_limit + 1))
+	# Can't sort by time using find instead of ls
+	# shellcheck disable=SC2012
+	ls -t "$_dir"/* 2>/dev/null | tail -n "+${_offset}" | xargs rm -f
+}
+
+############################################################
+
+ctdb_check_args "$@"
+
+case "$1" in
+init)
+	# Load/cache database options from configuration file
+	ctdb_get_db_options
+
+	if select_tdb_checker; then
+		check_persistent_databases || exit $?
+		check_non_persistent_databases
+	fi
+	;;
+monitor)
+	maybe_backup_persistent_tdbs
+	;;
+esac
+
+# all OK
+exit 0
diff --git a/ctdb/doc/ctdb-script.options.5.xml b/ctdb/doc/ctdb-script.options.5.xml
index 4f473b8b970..11597097a04 100644
--- a/ctdb/doc/ctdb-script.options.5.xml
+++ b/ctdb/doc/ctdb-script.options.5.xml
@@ -996,15 +996,16 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
 
   <refsect1>
     <title>
-      DATABASE SETUP
+      DATABASE HANDLING
       </title>
 
       <para>
-	CTDB checks the consistency of databases during startup.
+	CTDB checks the consistency of databases during startup and
+	provides a facility to backup persistent databases.
       </para>
 
       <refsect2>
-	<title>00.ctdb</title>
+	<title>95.database</title>
 
 	<variablelist>
 
@@ -1024,6 +1025,56 @@ CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=9000
 	    </listitem>
 	  </varlistentry>
 
+	  <varlistentry>
+	    <term>CTDB_PERSISTENT_DB_BACKUP_DIR=<parameter>DIRECTORY</parameter></term>
+	    <listitem>
+	      <para>
+		Create a daily backup tarball for all persistent TDBs
+		in DIRECTORY.  Note that DIRECTORY must exist or no
+		backups will be created.
+	      </para>
+	      <para>
+		Given that persistent databases are fully replicated,
+		duplication is avoid by only creating backups on the
+		current leader node.  To maintain a complete, single
+		set of backups, it makes sense for DIRECTORY to be in
+		a cluster filesystem.
+	      </para>
+	      <para>
+		This creates the backup from the
+		<command>monitor</command> event, which should be fine
+		because backing up persistent databases is a local
+		operation.  Users who do not wish do create backups
+		during the <command>monitor</command> event can choose
+		not to use this option and instead run
+		<command>/usr/local/etc/ctdb/ctdb-backup-persistent-tdbs.sh
+		-l <parameter>DIRECTORY</parameter></command> on all
+		nodes using a
+		<citerefentry><refentrytitle>cron</refentrytitle>
+		<manvolnum>8</manvolnum></citerefentry> job, which
+		will also need to manually manage backup pruning.
+	      </para>
+	      <para>
+		No default.  No daily backups are created.
+	      </para>
+	    </listitem>
+	  </varlistentry>
+
+	  <varlistentry>
+	    <term>CTDB_PERSISTENT_DB_BACKUP_LIMIT=<parameter>COUNT</parameter></term>


-- 
Samba Shared Repository



More information about the samba-cvs mailing list