Snapshots from same machine have different hostnames


#1

I use restic to backup my MacBook as scheduled by launchctl. (It runs a certain time every week, or whenever I next log in.) But my laptop moves around. Sometimes it’s at my home network, other times it’s on campus, etc.

I also have my home file server backing up to the same repo, leading to a snapshots list like this:

$ restic snapshots
ID        Date                 Host                        Tags        Directory
----------------------------------------------------------------------
c29d7dbe  2017-06-21 18:56:21  MyMacBook.home                          /Users/matt
e16ee1b0  2017-07-13 18:13:11  myfileserver                            /mnt/data
4e92f474  2017-07-17 10:28:07  MyMacBook.home                          /Users/matt
a7f3ac7f  2017-07-21 01:00:30  myfileserver                            /mnt/data
f61eb740  2017-07-21 01:00:50  myfileserver                            /mnt/data
86b5672c  2017-07-28 01:00:33  myfileserver                            /mnt/data
836d3ff8  2017-07-31 10:00:08  MyMacBook.home                          /Users/matt
c290bb80  2017-08-04 01:00:30  myfileserver                            /mnt/data
a5b1fa0f  2017-08-07 10:00:08  MyMacBook.home                          /Users/matt
175b4b6a  2017-08-11 01:00:34  myfileserver                            /mnt/data
a4372e40  2017-08-14 10:06:52  MyMacBook.local                         /Users/matt
f82ba886  2017-08-18 01:00:29  myfileserver                            /mnt/data
dd75b5d8  2017-08-25 01:00:31  myfileserver                            /mnt/data
27ed19fc  2017-08-28 10:07:00  byu01167038wks.app.byu.edu              /Users/matt

There’s only 2 machines backing up to this repo, but it looks like there are 4. My MacBook’s “Computer Name” hasn’t changed – but the network it’s on assigns it different names, I guess. My Will this be a problem when trying to restore all the files for my MacBook? Is there a way to rename these hosts?


Example: Scheduling regular backups on macOS
#2

Matt; I suppose you’re asking if you can rename the hosts in the snapshots that already exist. I don’t know, but see the --hostname argument to the backup command for future backups. That said, I doubt it will have any relevance on restore, it’s mostly a piece of information to help you identify snapshots more easily.


#3

Thanks. I’m aware of that, but trying to avoid having to figure out which hosts are actually the same, then running the command once per host! (And I dunno if it will overlap?) Basically, what are the implications of this.


#4

Indeed, hm. Restic will use the host name the system reports, and this seems to change rather often in your case.

It won’t be a problem at all when restoring. At least not when you manually specify the snapshot ID.

No, we don’t have a command for that yet, although the tag command is already able to modify snapshots (so the basic functionality is already there).

Having changing hostnames may lead to problems when forget is run: Restic splits the list of all snapshots into groups, by the set of dirs and by hostname. So for example when you run restic forget --keep-last 1 to only keep the last snapshot for each group, you’ll end up with ~4 snapshots instead of the expected two.

I’d suggest using restic backup --hostname MacBook or something similar to create a backup with a stable hostname.


#5

Thanks for the reply. Looks like --hostname is exactly what I need! Duly noted, and updated my macOS guide I posted earlier.

Tagging is a good idea too.