summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--obnamlib/plugins/backup_plugin.py9
-rw-r--r--yarns/0030-basics.yarn19
-rw-r--r--yarns/9000-implements.yarn8
-rw-r--r--yarns/obnam.sh9
5 files changed, 50 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d582cf5d..f1b58a1d 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,11 @@ Bug fixes:
hostname as the default value for `--client-name`. Reported by
SanskritFritz.
+* When a file was backed up, and later excluded with `--exclude`,
+ Obnam wouldn't remove it from the new backups. Now it does. Bug
+ fixed by Anssi Hannula, though his patch got changed because it no
+ longer applied.
+
Version 1.7.4, released 2014-03-31
--------------------------------
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py
index 99971d60..f312337e 100644
--- a/obnamlib/plugins/backup_plugin.py
+++ b/obnamlib/plugins/backup_plugin.py
@@ -983,6 +983,15 @@ class BackupPlugin(obnamlib.ObnamPlugin):
for old in old_pathnames:
if old not in new_pathnames:
self.repo.remove_file(self.new_generation, old)
+ else:
+ try:
+ st = self.fs.lstat(old)
+ except OSError:
+ pass
+ else:
+ if not self.can_be_backed_up(old, st):
+ self.repo.remove_file(self.new_generation, old)
+
# Files that are created after the previous generation will be
# added to the directory when they are backed up, so we don't
# need to worry about them here.
diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn
index 22ca0f1d..4bc8439b 100644
--- a/yarns/0030-basics.yarn
+++ b/yarns/0030-basics.yarn
@@ -247,6 +247,25 @@ Time to backup.
AND user U restores their latest generation in repository R into X
THEN L, restored to X, matches manifest M
+Excluded, already backed up files, are not included in next generation
+----------------------------------------------------------------------
+
+Until Obnam version 1.7.4, but fixed after that, Obnam had a bug where
+a file that was not excluded became excluded was not removed from new
+backup generations. In other words, if file `foo` exists and is backed
+up, and the user then makes a new backup with `--exclude=foo`, the new
+backup generation still contains `foo`. This is clearly a bug. This
+scenario verifies that the bug no longer exists, and prevents it from
+recurring.
+
+ SCENARIO new generation drops excluded, previously backed up files
+ GIVEN a file foo in L, with data
+ WHEN user U backs up directory L to repository R
+ GIVEN user U sets configuration exclude to foo
+ WHEN user U backs up directory L to repository R
+ AND user U restores their latest generation in repository R into X
+ THEN L, restored to X, is empty
+
Changing backup roots
---------------------
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index 300112bb..4fb0fc00 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -533,6 +533,14 @@ original one in live data.
new=$(stat -c %b "$DATADIR/$MATCH_3/$DATADIR/$MATCH_2/$MATCH_1")
test "$old" -lt "$new"
+Check that a restored directory is empty.
+
+ IMPLEMENTS THEN (\S+), restored to (\S+), is empty
+ if find "$DATADIR/$MATCH_2/$DATADIR/$MATCH_1" -mindepth 1 | grep .
+ then
+ die "$DATADIR/$MATCH_2/$DATADIR/$MATCH_1 isn't empty"
+ fi
+
Checks on contents of files
---------------------------
diff --git a/yarns/obnam.sh b/yarns/obnam.sh
index 54d76c02..a6bae7e6 100644
--- a/yarns/obnam.sh
+++ b/yarns/obnam.sh
@@ -16,6 +16,15 @@
# =*= License: GPL-3+ =*=
+# A helper to print an error message and terminate.
+
+die()
+{
+ printf '%s\n' -- "$*" 1>&2
+ exit 1
+}
+
+
# Run Obnam in a safe way that ignore's any configuration files
# outside the test. The first argument MUST be the client name. The
# configuration file $DATADIR/$1.conf is used, if it exists. In addition,