Keep a synced directory's unsent edits after a restore

Move a synced directory's unsent edits onto a restored instance, from the list of files that marfa folders remove gives you.

A directory that held edits the old server never received can't send them to the new instance, which holds neither the folder's state nor its key: its push is refused instance_changed. Instead, let a new directory send them. A directory with nothing unsent needs only Fix a folder.

Before you start, restore the backup, settle its final address, and sign the CLI in to it. Do the steps once for each directory, on the computer that holds it.

Remove the directory from its folder

Once a server at the folder's address answers as another instance, remove takes the directory off its folder even though edits wait. Its files stay as they are, and it lists each one that holds a change the old server never received:

Terminal
marfa folders remove ~/Documents/Home
/Users/sam/Documents/Home no longer follows the folder 01a1f46f-bed0-7310-bb7c-840868eb64ac; its files stay
4 write(s) could not be sent, because another Marfa instance answers at the folder's server; these files hold the changes this folder could not send:
  changed  Packing list.md
  new      New idea.md
  moved    Trips/Lisbon.md, from Lisbon.md
  deleted  Old plan.md

Keep this list: removing the directory deletes the record of what waited, and a deletion or a move is in no file. Its numbered steps follow, and --json gives the same as folder, unsent and files.

Add a new directory in its place

Move the directory to a name that doesn't exist yet (mv puts a directory inside one that does), then add the folder again by its ID, which the restore kept, and push. The new directory fills with the restored instance's copy of every file.

mv ~/Documents/Home ~/Documents/Home.before-restore
marfa folders add ~/Documents/Home --folder 01a1f46f-bed0-7310-bb7c-840868eb64ac
marfa folders push ~/Documents/Home

Make each change again

In the new directory, delete each deleted file again, and move each moved file again from where it was. Then copy back only the changed, new and moved files from Home.before-restore, never its .marfa:

rm ~/Documents/Home/"Old plan.md"
mkdir -p ~/Documents/Home/Trips && mv ~/Documents/Home/Lisbon.md ~/Documents/Home/Trips/
cp ~/Documents/Home.before-restore/{"Packing list.md","New idea.md"} ~/Documents/Home/
cp ~/Documents/Home.before-restore/Trips/Lisbon.md ~/Documents/Home/Trips/

Copying back only the named files keeps the edits another computer sent to the others.

Compare the two directories

diff -rq --exclude=.marfa ~/Documents/Home.before-restore ~/Documents/Home

A file that differs but isn't on the list may hold a change the folder sent after the backup was made, which the new instance lacks. Check it, and copy it back if the old copy is the one to keep. A note can also differ only by the details Marfa writes at its top.

Push until nothing waits

marfa folders push ~/Documents/Home
marfa folders status ~/Documents/Home

Push again until status shows nothing waiting: a deleted file's item is binned only once the folder's grace for a rename has passed. Keep Home.before-restore until then. Another computer with unsent edits follows these steps for its own directory.

On this page