[Pkg-openldap-devel] [openldap] 06/29: r1435 at pulsar: torsten | 2005-03-15 01:15:56 +0100 Converted the backup dir to a more simple scheme which should be save against accidental overwriting.
Timo Aaltonen
tjaalton-guest at alioth.debian.org
Thu Oct 10 05:34:47 UTC 2013
This is an automated email from the git hooks/post-receive script.
tjaalton-guest pushed a commit to annotated tag 2.2.23-0.pre6
in repository openldap.
commit 6950bf8be5eb135d0737c37c56067b6c16216d76
Author: Torsten Landschoff <torsten at debian.org>
Date: Wed Mar 16 14:06:43 2005 +0000
r1435 at pulsar: torsten | 2005-03-15 01:15:56 +0100
Converted the backup dir to a more simple scheme which should be save
against accidental overwriting.
---
debian/changelog | 2 ++
debian/slapd.postinst | 29 +++++++++++++----------------
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 1e36d6e..00a9488 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,8 @@ openldap2.2 (2.2.23-0.pre6) experimental; urgency=low
error message even if the user has already seen it before.
* debian/slapd.postinst (compute_backup_path): Make function more robust
in case we don't know the old version or the suffix of the database.
+ Converted the backup dir to a more simple scheme which should be save
+ against accidental overwriting.
--
diff --git a/debian/slapd.postinst b/debian/slapd.postinst
index 3a03632..68ca4ee 100644
--- a/debian/slapd.postinst
+++ b/debian/slapd.postinst
@@ -16,23 +16,20 @@ compute_backup_path() { # {{{
dirname="$1"
basedn="$2"
- # If we are installing from scratch and something got into the
- # /var/lib/ldap directory it could well be that we don't have a
- # value for $OLD_VERSION - use the date and time instead
- if [ "$OLD_VERSION" ]; then
- echo -n "/var/backups/slapd-$OLD_VERSION/"
- else
- echo -n "/var/backups/slapd-`date +%Y%m%d-%H:%M:%S`/"
+ # Computing the name of the backup directory from the old version,
+ # the suffix etc. all makes me feel worried. I'd rather have a
+ # directory name which is not going to exist. So the simple
+ # scheme we are using now is to compute the filename from the
+ # directory name and appending date and time. And we check if it
+ # exists to be really sure... -- Torsten
+
+ local target
+ target=`echo "$dirname"|cut -c 2-|tr / _`-`date +%Y%m%d-%H:%M:%S`
+ if [ -e "/var/backups/$target" ]; then
+ echo >&2 " Backup path $target exists. Giving up..."
fi
- # Just as well we can know the suffix if we were able to parse the
- # config file or not. If the latter we use the name "unknown"
- # as the final path element.
- if [ "$basedn" ]; then
- echo -n "$basedn"
- else
- echo -n "unknown"
- fi
+ echo "/var/backups/$target"
}
# }}}
@@ -49,7 +46,6 @@ move_old_database_away() { # {{{
local databasedir backupdir
databasedir="$1"
suffix="$2"
- backupdir=`compute_backup_path "$databasedir" "$suffix"`
if is_empty_dir "$databasedir"; then
return
@@ -60,6 +56,7 @@ move_old_database_away() { # {{{
# include mount points as well anyway, but it's much less likely.
db_get slapd/move_old_database
if [ "$RET" = true ]; then
+ backupdir=`compute_backup_path "$databasedir" "$suffix"`
echo -n " Moving $databasedir to $backupdir... " >&2
mkdir -p "$backupdir"
mv "$databasedir"/* "$backupdir"/
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-openldap/openldap.git
More information about the Pkg-openldap-devel
mailing list