diff options
author | Lars Wirzenius <liw@liw.fi> | 2014-01-24 18:56:56 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2014-01-24 18:56:56 +0000 |
commit | e1bc54aebce156815a617a079c03b7689b832066 (patch) | |
tree | c262acb249be88406655ff0ded7cd2396c6ad434 | |
parent | fbc4ec886a8838cf3188d95e0ea74e104ba99f1b (diff) | |
download | obnam-e1bc54aebce156815a617a079c03b7689b832066.tar.gz |
Convert --exclude-cache test to yarn
-rwxr-xr-x | tests/exclude-cachedir.script | 28 | ||||
-rw-r--r-- | yarns/0030-basics.yarn | 35 | ||||
-rw-r--r-- | yarns/9000-implements.yarn | 28 |
3 files changed, 63 insertions, 28 deletions
diff --git a/tests/exclude-cachedir.script b/tests/exclude-cachedir.script deleted file mode 100755 index 7c555867..00000000 --- a/tests/exclude-cachedir.script +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Copyright 2011 Lars Wirzenius -# -# 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/>. - -set -e - -cachedir="$DATADIR/data/cache" -mkdir "$cachedir" -echo -n 'Signature: 8a477f597d28d172789f06886806bc55' \ - > "$cachedir/CACHEDIR.TAG" -echo foo > "$cachedir/foo" - -$SRCDIR/tests/backup --exclude-caches -$SRCDIR/tests/restore - -find "$DATADIR/restored" -name cachdir diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn index 3324dc45..5d563f0b 100644 --- a/yarns/0030-basics.yarn +++ b/yarns/0030-basics.yarn @@ -101,3 +101,38 @@ than a real one. WHEN user U pretends to back up directory L to repository R GIVEN a manifest of directory R in M2 THEN manifests M1 and M2 match + +Exclude cache directories +------------------------- + +The [Cache directory tagging] standard provides an easy way to mark +specific directories as cache directories, which means their data is +easy to re-create (or re-download). Such data is often not worth +backing up. The `--exclude-caches` option tells Obnam to exclude any +directories tagged like that. + +[Cache directory tagging]: http://www.bford.info/cachedir/ + + SCENARIO exclude cache directories + GIVEN 1k of new data in directory L/wanted + +The directory `L` now contains what we want to restore: only the +wanted data, no cache directory. This is a good time to create the +manifest. + + AND a manifest of directory L in M + +We now create the cache directory and tag it. Then we backup, +excluding caches, and restore, and verify. However, there's a snag: +the manifest has a modification time for `L` that is wrong: the +creation of the cache directory modifies it. Thus, we also modify the +manifest to update the first `Mtime` field, i.e., the one for the +directory `L`. + + AND 1k of new data in directory L/cache + AND directory L/cache is tagged as a cache directory + AND manifest M has Mtime for the first entry set from L + AND user U sets configuration exclude-caches to yes + 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, matches manifest M diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn index b8733e39..f70ccd07 100644 --- a/yarns/9000-implements.yarn +++ b/yarns/9000-implements.yarn @@ -54,6 +54,13 @@ backup programs (regular files with data and no holes). IMPLEMENTS GIVEN directory (\S+) with interesting filesystem objects "$SRCDIR/mkfunnyfarm" "$DATADIR/$MATCH_1" +Some directories will be tagged as cache directories +(see [Cache directory tagging](http://www.bford.info/cachedir/)). + + IMPLEMENTS GIVEN directory (\S+) is tagged as a cache directory + printf 'Signature: 8a477f597d28d172789f06886806bc55' \ + > "$DATADIR/$MATCH_1/CACHEDIR.TAG" + Manifest creation and checking ------------------------------ @@ -82,6 +89,22 @@ We may also need to check two manifests against each other. IMPLEMENTS THEN manifests (\S+) and (\S+) match diff -u "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2" +In a special case, we may need to update the `Mtime` for the first +entry in a manifest. This is used, at least, when testing cache +directory exclusion: we create wanted data, then create a manifest, +then add the cache directory. This invalidates the Mtime for the first +entry. + + IMPLEMENTS GIVEN manifest (\S+) has Mtime for the first entry set from (\S+) + x=$(date -r "$DATADIR/$MATCH_2" '+Mtime: %Y-%m-%d %H:%M:%S +0000') + awk -v "x=$x" ' + !x && /^Mtime:/ { print x; next } + /^$/ { x = 1 } + { print } + ' "$DATADIR/$MATCH_1" > "$DATADIR/new-manifest" + mv "$DATADIR/new-manifest" "$DATADIR/$MATCH_1" + + Obnam configuration management ------------------------------ @@ -107,6 +130,11 @@ someone else. IMPLEMENTS GIVEN a user (\S+) calling themselves (\S+) add_to_config "$MATCH_1" client-name "$MATCH_2" +Add a setting to a client's configuration file. + + IMPLEMENTS GIVEN user (\S+) sets configuration (\S+) to (\S+) + add_to_config "$MATCH_1" "$MATCH_2" "$MATCH_3" + Backing up ---------- |