#!/bin/sh # Copyright 2012-2014 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 . set -eu if [ "$#" != 1 ] then echo "usage: see source" 1>&2 exit 1 fi N="$1" tempdir="$(mktemp -d)" echo "Temporary directory: $tempdir" cat < "$tempdir/conf" [config] repository = $tempdir/repo root = $tempdir/data log = $tempdir/obnam.log trace = larch checkpoint = 1m lock-timeout = 1 log-keep = 16 # log-level = debug trace = larch, obnamlib EOF # Do a minimal backup to make sure the repository works at least once, # without the crash-limit option mkdir "$tempdir/data" ./obnam backup --no-default-config --config "$tempdir/conf" genbackupdata --create=100m "$tempdir/data" echo "crash-limit = $N" >> "$tempdir/conf" while true do # There's no need to delete this file because the first Exception message # that appears in the file will terminate the test. # rm -f "$tempdir/obnam.log" echo "Trying backup with at most $N writes to repository" ./obnam force-lock --no-default-config --config "$tempdir/conf" \ 2>/dev/null if ./obnam backup --no-default-config --config "$tempdir/conf" 2>/dev/null then echo "Backup finished ok, done" break fi if ! grep -q '^Exception: Crashing as requested' "$tempdir/obnam.log" then echo "Backup terminated because of unrequested crash" 1>&2 exit 1 fi # ./obnam fsck --no-default-config --config "$tempdir/conf" || true done rm -rf "$tempdir" echo "OK"