11 Sep 2014 Emu by example, part 4 11 Sep 2014

Part 4: Squash and prune

In the last post we covered how to identify snapshots uniquely using their IDs and various shorthand aliases, and how to verify and checkout individual snapshots. Today we’re going to cover two further important topics: How to merge snapshots, and how to remove snapshots.

squash

The squash command accepts multiple chronologically ordered snapshots as arguments, and squashes each of them together to form a new, merged, snapshot. That is, if we squash together snapshots A and B, the resulting snapshot C would contain all of the files of A and B, without duplicates. Where there are competing files, the most recent snapshot’s file will be preserved. For example, let’s say we wanted to squash the last four snapshots together:

The output explains a lot about the mechanics of squash. First, it merges each snapshot in turn into a new one. Once this new snapshot has been fully merged, the squashed snapshots are removed, and the new snapshot is inserted into the snapshot history, being assigned an ID and date. Let’s now squash the two most recent snapshots:

Notice now that since we have created a new snapshot out of the HEAD, we must assign this new snapshot as HEAD in order to preserve the snapshot history. Squash is most useful when we want to preserve the data contained within multiple snapshots, without also preserving the history of those unique snapshots. The history that is lost is the differences between the squashed snapshots. Now we’re going to take a look at the prune command, which is how we remove history in emu.

prune

The squash examples have already demonstrated the effects of prune. Pruning a snapshot means simply removing it, and all associated data, from the backup sink. The most common use case for prune is to simply remove old snapshots that we’re no longer interested in preserving. For example, to remove the five oldest snapshots from sink origin: