I’m trying to understand behavior that I’m seeing with restic during backup and restore.
Let’s say I have a data directory that I want to back up, /Users/steve/tmp/restic-test/data
.
Scenario #1
- Change pwd to my data dir:
cd /Users/steve/tmp/restic-test/data
- Take backup:
restic backup .
- See backup has full directory stored:
restic snapshots
->/Users/steve/tmp/restic-test/data
- Restore into a new directory:
restic restore --target /Users/steve/tmp/restic-test/restored-data <snapshotID>
- See contents of
/Users/steve/tmp/restic-test/data
restored into/Users/steve/tmp/restic-test/restored-data
.
So far, so good.
Scenario #2
- Change pwd to the parent of my data dir:
cd /Users/steve/tmp/restic-test
- Take backup:
restic backup data/
- See backup has full directory stored:
restic snapshots
->/Users/steve/tmp/restic-test/data
- Restore into a new directory:
restic restore --target /Users/steve/tmp/restic-test/restored-data <snapshotID>
- See the data dir itself restored into
/Users/steve/tmp/restic-test/restored-data
, i.e. now I see/Users/steve/tmp/restic-test/restored-data
.
OK, so it seems that restic is internally keeping track of the relative path I used when I took the backup, and restoring based on that.
Scenario #3
- (from any pwd) take backup specifying absolute path:
restic backup /Users/steve/tmp/restic-test/data
- See backup has full directory stored:
restic snapshots
->/Users/steve/tmp/restic-test/data
- Restore into a new directory:
restic restore --target /Users/steve/tmp/restic-test/restored-data <snapshotID>
- See the full tree of the backed up dir’s path itself restored into
/Users/steve/tmp/restic-test/restored-data
, i.e. now I see/Users/steve/tmp/restic-test/Users/steve/tmp/restic-test/data
.
So, it seems that restic is retaining info about the relative or absolute path that I’m using when backing up, even though it only displays the absolute path when looking at restic snapshots
.
Is this expected behavior? If so, is it documented anywhere? It is actually useful for use to have, but if it is intended, it would be really useful to be able to view the relative paths somewhere in the restic snapshots
output so we know ahead of time what will happen when we restore a given snapshot.