summaryrefslogtreecommitdiff
path: root/yarns/obnam.sh
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-02-06 23:25:51 +0000
committerLars Wirzenius <liw@liw.fi>2014-02-06 23:25:51 +0000
commit3713aabaaba16cad2ecfa85cb556755ffe2d664f (patch)
tree061a75a9439ee8d87129bc420278732defcb8f6c /yarns/obnam.sh
parent6b6387c357faab0153c6dd9207dfec1e3779e7fc (diff)
downloadobnam-3713aabaaba16cad2ecfa85cb556755ffe2d664f.tar.gz
Make exclude-caches scenario clearer, robust
Originally, we would create L/wanted, then do a manifest, then create L/cache, then backup, restore, verify. This would sometimes fail, if the full-second timestamp of L would change when L/cache was created. So we (well, I) changed it so that we fiddled with the manifest just before making a backup, but this was weird and confusing and would still sometimes fail. This should now be much clearer and therefore more robust.
Diffstat (limited to 'yarns/obnam.sh')
-rw-r--r--yarns/obnam.sh30
1 files changed, 29 insertions, 1 deletions
diff --git a/yarns/obnam.sh b/yarns/obnam.sh
index 55fc2336..c19f532e 100644
--- a/yarns/obnam.sh
+++ b/yarns/obnam.sh
@@ -121,9 +121,37 @@ normalise_manifest_times()
}
+# Remove "Nlink" lines for directories. It is rarely a useful thing
+# compare exactly, unlike for non-directories, since it is merely
+# extra checking that the right number of subdirectories exist. That
+# extra checking is both unnecessary (if the subdirs are in the
+# manifest, they already get checked), and harmful (if a subdirectory
+# is excluded from a backup, it won't be in the restored data
+# manifest, but the link count will be wrong).
+
+remove_nlink_for_directories()
+{
+ # This assumes tat Mode comes before Nlink, which is does in
+ # summain output.
+ awk '
+ $1 == "Mode:" && $2 ~ /^40/ { isdir = 1 }
+ $1 == "Nlink:" && isdir { skip }
+ NF > 0 { paragraph = paragraph $0 "\n" }
+ NF == 0 && paragraph {
+ printf "%s\n", paragraph
+ paragraph = ""
+ isdir = 0
+ }
+ END { if (paragraph) printf "%s", paragraph }
+ ' "$DATADIR/$MATCH_2" > "$DATADIR/$MATCH_2.new"
+}
+
+
# Create a manifest with summain of a file or a directory.
manifest()
{
- summain -r "$1" --exclude Ino --exclude Dev | normalise_manifest_times
+ summain -r "$1" --exclude Ino --exclude Dev |
+ normalise_manifest_times |
+ remove_nlink_for_directories
}