Reconcile a duplicate vault copy inside vault

What I’m trying to do

I somehow copied my vault inside my vault.

cd MYVAULTNAME
tree -L 1

and the result:

├── MYVAULTNAME
│   ├── file.PDF
│   ├── ... etc ...

The vault seems like a mostly identical copy. If I have to guess how this happened, I probably copied the vault at some point, or used Obsidian’s menu to “sync a new vault” inside the already existing vault. Another mistake I did was having iCloud sync enabled on this vault on one of my computers. (I think the default location of ~/Documents for Obsidian on MacOS is a mistake, since default MacOS syncs that folder to iCloud drive…). Regardless, let’s fix this!

Few things:

  1. It’s relatively big with 631 files hence I don’t feel like I could resolve this manually.
  2. I don’t know when this happened, may have been 1-2 years ago
  3. When I noticed it, I tried editing only the root vault’s contents - although I may have inadvertendly edited some of the duplicate vault’s contents
  4. This is synced in Obsidian Sync, so it’s the latest source of truth

Things I have tried

  • Nothing

Here are some ideas:

  • write a script that compares files from the root and the copy, including latest modified date - take only the latest modified one. One big con here is that it can result in data loss - e.g if original note A was modified in May 2024, but the copy was modified in March 2024 – the strict would only take the original one which wouldn’t include the copy’s changes

  • write a script that compares files from the root and the copy, including latest modified date - flag the ones that are inconsistent, then manually resolve it. This is doable, as I don’t imagine I edited more than 50 of the 631 files

  • use some pre-made tool for somebody else that hit this problem. This is my preferred solution and the reason why I’m posting here. Hopefully someone can help :pray:

I don’t think any premade told exists for that, but I’ve been wrong before. But I’d like to suggest a slightly different approach, and that is as follows:

  • Loop through the original folder structure (width first not depth), where you for each file checks to see if there is a corresponding file in the shadow copy. If so move that file out into a separate folder structure
  • Do a folder comparison and merge operation on the resulting two folders into your original folder

This procedure would ensure that you don’t loose any information before you actively decide which version to keep in the merge process, and even then you’ve got a backup of the files.

In any case, I’d also make a backup of the entire structure before doing anything.

1 Like

+1 to backing up first.

You might also consider removing the nested vault, and doing the scripted operations parallel to each other instead of from inside one.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.