Best practice for restore to new computer

I will probably buy a new laptop, probably Pop!_OS pre-installed, in the next several months. Thinking ahead I am trying to mentally rehearse how to reconstitute my home directory (Pop 22.04). I back up only from $HOME with some exclusions, and I do not expect to need everything on my new device (unless it is just easier to do a complete $HOME restore).

Are there best practices for something like this? When I have restored a single file or folder in the past, I usually use the mount command followed by cp. However, I am thinking that would not be the most efficient for the entire $HOME. Also, my new laptop will already have a user and home/[user] with my name. Is restore to a tmp directory the answer? What have some expert users done in this situation?

Do I need to run restic -r $myrepo init on a new computer? How do I get the newly initialized repo to adopt the snapshots from the old computer’s backups?

Now, I’m not an expert but whenever I switch to a fresh install, I also mount the backup repo and then first get all the .folders I know I need, especially the stuff in .config and .local, .bashrc and so on. I copy those using two pane view in Nemo. After that I use rsync to copy over the other folders like Documents, Music etc. because rsync allows me to continue if I need to take a break inbetween for rebooting or something like that.

A fresh install to me is a nice opportunity to get rid of stuff that is there but really isn’t necessary anymore. And if you miss something later, you can always come back and get it.

That said the last two times I just used dd to clone the whole disk which only works if the new disk is bigger than the old one.

I’d probably just copy the files to an external disk, then copy them to the new computer.

Thanks for your suggestions. The other thing I forgot to ask was how to start with a fresh instance of Restic on a new system. Do I need to run restic -r $myrepo init on a new computer? How do I get the newly initialized repo to adopt the snapshots from the old computer’s backups? (I think I will edit my OP to add this question.)

OK. I found this from 2018 which seems to answer my restic...init question:

My confusion was because I assumed there was a key stored locally on the old computer, but I guess that is not how authorization works in this case.

Exactly. Init is only necessary to turn a standard folder into a restic repository, just like with git init. What you’re looking for is the --parent option that you can read about here. Basically you tell restic to use a certain snapshot as the parent of your new snapshot.

1 Like

And even this is not needed. I would actually not use it. What will happen is that first backup from new machine will take a bit longer as all files will be fully read/hashed/compared with stored data. If they are already in repo nothing new will be backed up anyway (but some metadata). Then subsequent backups will be as fast as before.


@nicnab @kapitainsky I read the restic backup --help and the docs Backing up > File Change Detection section Nico linked to above.

My first action on my new system with Restic would be restic -r $repoFromMyOldSystem mount mountpoint so that I copy what I want from my old home folder backup.

After that I would want to backup my new system to the same repo.

The previous backup snapshot, called “parent” snapshot in restic terminology, is determined as follows. By default restic groups snapshots by hostname and backup paths, and then selects the latest snapshot in the group that matches the current backup.

If I understand that correctly so long as my hostname and $HOME are exactly the same, no problem, even if it is a new machine? As long as I have the same hostname and username? But if I decide to use a different OS which will by default have a different hostname? Then using --parent or --group-by paths (if I have same path, ie, $HOME on new machine but different hostname). And those flags will only be needed once? After that restic will look at my latest new-machine-generated snapshot as the “parent”.

Sorry to be so detail oriented. It is my nature, and I find that mental rehearsal, planning ahead is a good way to avoid problems.

I think you are trying to over-engineer it. Restore your backup and start new ones to the same repo - it is simple like that. Trying to avoid re-reading data by specifying manually parent snapshot makes sense when you have so much data that even reading it can take days. From your description this is not the case - so your first backup from new machine will take hours instead of minutes - that’s it.

If things change (hostname, path) and you want to maintain continuity for example for forget operations policy use tags. If you will maintain host name and path then there is really nothing to do.

1 Like

Also, you can set your hostname as you wish - on any distro. Search online for /etc/hostname. If that still differs, see @kapitainsky’s post above regarding forget continuity.

1 Like

Thank you both for your help. I understand this better now.