diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-12-04 19:11:51 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-12-04 19:11:51 +0000 |
commit | 606a452e51a6508fcd0a962f84549ab02444137c (patch) | |
tree | 67ab963e29afe64b09cbe568d14bb28f0b90a8e8 /yarns | |
parent | 4640a881c2263cc2cfcb6a0ed3f75170e93284da (diff) | |
download | obnam-606a452e51a6508fcd0a962f84549ab02444137c.tar.gz |
Add test for backing up sparse files
Diffstat (limited to 'yarns')
-rw-r--r-- | yarns/0030-basics.yarn | 25 | ||||
-rw-r--r-- | yarns/9000-implements.yarn | 28 |
2 files changed, 53 insertions, 0 deletions
diff --git a/yarns/0030-basics.yarn b/yarns/0030-basics.yarn index 7cdc3ba7..0106eb0d 100644 --- a/yarns/0030-basics.yarn +++ b/yarns/0030-basics.yarn @@ -22,3 +22,28 @@ program must be able to handle. WHEN user backs up live data THEN user can restore their data correctly AND user can fsck the repository + +Backup sparse files +------------------- + +Sparse files present an interesting challenge to backup programs. Most +people have none, but some people have lots, and theirs can have very +large holes. For example, at work I often generate disk images as +raw disk images in sparse files. The image may need to be, say 30 +gigabytes in size, even though it only contains one or two gigabyte of +data. The rest is a hole. + +A backup program should restore a sparse file as a sparse file. +Otherwise, the 30 gigabyte disk image file will, upon restore, use 30 +gigabytes of disk space, rather than one. That might make restoring +impossible. + +Unfortunately, it is not easy to (portably) check whether a file is +sparse. We'll settle for making sure the restored file does not use +more disk space than the one in live data. + + SCENARIO backup a sparse file + GIVEN a file S in live data, with a hole, data, a hole + WHEN user backs up live data + THEN user can restore their data into X + AND restored file S in X doesn't use more disk diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn index 41b6db4d..2cffdd69 100644 --- a/yarns/9000-implements.yarn +++ b/yarns/9000-implements.yarn @@ -34,6 +34,15 @@ for single-client scenarios. IMPLEMENTS GIVEN (\S+) of live data genbackupdata --quiet --create "$MATCH_1" "$LIVEDATA" +We also need to generate a sparse file. A sparse file has at least one +hole in it, and it may matter where the hole is: at the beginning, +middle, or end of the file. Thus, we provide a way for scenarios to +specify that. + + IMPLEMENTS GIVEN a file (\S+) in live data, with (.+) + mkdir -p "$LIVEDATA" + "$SRCDIR/mksparse" "$LIVEDATA/$MATCH_1" "$MATCH_2" + Backing up and verifying a backup --------------------------------- @@ -59,3 +68,22 @@ We further verify that the repository itself is OK, by running IMPLEMENTS THEN user can fsck the repository run_obnam fsck -r "$REPO" + +Restoring data +-------------- + +We need a way to restore data from a test backup repository. + + IMPLEMENTS THEN user can restore their data into (\S+) + run_obnam restore -r "$REPO" --to "$DATADIR/$MATCH_1" + +Checks on files +--------------- + +Check that a restored file uses at most as much disk space as the +original one in live data. + + IMPLEMENTS THEN restored file (\S+) in (\S+) doesn't use more disk + old=$(stat -c %b "$LIVEDATA/$MATCH_1") + new=$(stat -c %b "$DATADIR/$MATCH_2/$LIVEDATA/$MATCH_1") + test "$old" -lt "$new" |