1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
#!/usr/bin/env bash
. ./wvtest-bup.sh || exit $?
. dev/lib.sh || exit $?
set -o pipefail
top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?
export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"
bup() { "$top/bup" "$@"; }
WVPASS cd "$tmpdir"
WVSTART "index excludes bupdir"
WVPASS force-delete src "$BUP_DIR"
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS bup random 128k >src/b
WVPASS mkdir src/d src/d/e
WVPASS bup random 512 >src/f
WVPASS bup index -ux src
WVPASS bup save -n exclude-bupdir src
WVPASSEQ "$(bup ls -AF "exclude-bupdir/latest/$tmpdir/src/")" "a
b
d/
f"
WVSTART "index --exclude"
WVPASS force-delete src "$BUP_DIR"
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS bup random 128k >src/b
WVPASS mkdir src/d src/d/e
WVPASS bup random 512 >src/f
WVPASS bup random 512 >src/j
WVPASS bup index -ux --exclude src/d --exclude src/j src
WVPASS bup save -n exclude src
WVPASSEQ "$(bup ls "exclude/latest/$tmpdir/src/")" "a
b
f"
WVPASS mkdir src/g src/h
WVPASS bup index -ux --exclude src/d --exclude $tmpdir/src/g --exclude src/h \
--exclude "$tmpdir/src/j" src
WVPASS bup save -n exclude src
WVPASSEQ "$(bup ls "exclude/latest/$tmpdir/src/")" "a
b
f"
WVSTART "index --exclude-from"
WVPASS force-delete src "$BUP_DIR"
WVPASS bup init
WVPASS mkdir src
WVPASS echo "src/d
$tmpdir/src/g
src/h
src/i" > exclude-list
WVPASS touch src/a
WVPASS bup random 128k >src/b
WVPASS mkdir src/d src/d/e
WVPASS bup random 512 >src/f
WVPASS mkdir src/g src/h
WVPASS bup random 128k > src/i
WVPASS bup index -ux --exclude-from exclude-list src
WVPASS bup save -n exclude-from src
WVPASSEQ "$(bup ls "exclude-from/latest/$tmpdir/src/")" "a
b
f"
WVPASS rm exclude-list
# bup index --exclude-rx ...
# ==========================
WVSTART "index --exclude-rx '^/foo' (root anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS mkdir src/sub1
WVPASS mkdir src/sub2
WVPASS touch src/sub1/a
WVPASS touch src/sub2/b
WVPASS bup index -u src --exclude-rx "^$(pwd)/src/sub1/"
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub2
./sub2/b"
WVSTART "index --exclude-rx '/foo$' (non-dir, tail anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src --exclude-rx '/foo$'
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub
./sub/foo
./sub/foo/a"
WVSTART "index --exclude-rx '/foo/$' (dir, tail anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src --exclude-rx '/foo/$'
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./foo
./sub"
WVSTART "index --exclude-rx '/foo/.' (dir content)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src --exclude-rx '/foo/.'
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./foo
./sub
./sub/foo"
# bup index --exclude-rx-from ...
# ===============================
WVSTART "index --exclude-rx-from"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS mkdir src/sub1
WVPASS mkdir src/sub2
WVPASS touch src/sub1/a
WVPASS touch src/sub2/b
# exclude-rx-file includes blank lines to check that we ignore them.
WVPASS echo "^$(pwd)/src/sub1/
" > exclude-rx-file
WVPASS bup index -u src --exclude-rx-from exclude-rx-file
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub2
./sub2/b"
# bup restore --exclude-rx ...
# ============================
WVSTART "restore --exclude-rx '^/foo' (root anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS mkdir src/sub1
WVPASS mkdir src/sub2
WVPASS touch src/sub1/a
WVPASS touch src/sub2/b
WVPASS bup index -u src
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp --exclude-rx "^/sub1/" /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub2
./sub2/b"
WVSTART "restore --exclude-rx '/foo$' (non-dir, tail anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo$' /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub
./sub/foo
./sub/foo/a"
WVSTART "restore --exclude-rx '/foo/$' (dir, tail anchor)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/$' /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./foo
./sub"
WVSTART "restore --exclude-rx '/foo/.' (dir content)"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS touch src/foo
WVPASS mkdir src/sub
WVPASS mkdir src/sub/foo
WVPASS touch src/sub/foo/a
WVPASS bup index -u src
WVPASS bup save --strip -n bupdir src
WVPASS bup restore -C buprestore.tmp --exclude-rx '/foo/.' /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./foo
./sub
./sub/foo"
# bup restore --exclude-rx-from ...
# =================================
WVSTART "restore --exclude-rx-from"
WVPASS rm -rf src "$BUP_DIR" buprestore.tmp
WVPASS bup init
WVPASS mkdir src
WVPASS touch src/a
WVPASS touch src/b
WVPASS mkdir src/sub1
WVPASS mkdir src/sub2
WVPASS touch src/sub1/a
WVPASS touch src/sub2/b
WVPASS bup index -u src
WVPASS bup save --strip -n bupdir src
WVPASS echo "^/sub1/" > exclude-rx-file
WVPASS bup restore -C buprestore.tmp \
--exclude-rx-from exclude-rx-file /bupdir/latest/
actual="$(WVPASS cd buprestore.tmp; WVPASS find . | WVPASS sort)" || exit $?
WVPASSEQ "$actual" ".
./a
./b
./sub2
./sub2/b"
WVPASS rm -rf "$tmpdir"
|