Retain Files Not Present in the Backup

Currently, I've been having some fun experimenting with a script that keeps 2 computers in sync with the same DOpus config (where it makes sense), all fully automated.
I wanted a 100% internal DOpus solution, so I adapted the approach to fit that requirement. Keep in mind that this setup can change based on your needs and available resources (like if you want to store backups in the cloud, use a webdav, etc.). Right now, I use the cloud to automatically upload and download backups for synchronization.
The method I've been using, which has been working well, goes like this:

To create a backup (I usually run this OnStartup, to have a backup in the cloud, or manually when I make changes I want to sync):

  • Create a backup using Prefs BACKUP=all.
  • Upload the backup to the cloud in \DO_Backup\%THISCOMPUTERNAME% via HttpRequest.
  • Set a global variable named backup_date with the current date and time.

On Startup:

  • Connect to the chosen host via HttpRequest.
  • Get a folder list for \DO_Backup\%OTHERCOMPUTERNAME% (if exists).
  • Check for the newest file (your chosen host should let you get metadata for all the files in that folder without downloading them first).
  • If the backup_date variable is older than the newest file:
    • Download the newest file (new_backup).
    • Create a backup (let's call it local_backup).
    • Process the downloaded backup. *
    • Restore the downloaded backup.
    • Profit!

One little issue I encountered early on was that after downloading the backup from the other computer, I processed it to remove some info that didn’t make sense to sync (like smart favorites, recent items, aliases, etc.) by simply deleting those related files. But if you use "replace the entire configuration when restoring", the removed files from the new_backup (which still exist in the current setup) are deleted. My current solution is to first copy those files from the local_backup to the new_backup, and then restore using the resulting backup.

Would there perhaps be a better way to do that 'merge'?

(Maybe it would be nice to add an option to replace (and not delete) all the files in the backup, so the intentionally missing files remain from the last configuration).

Hope that makes sense!

You need a list of files that you want to delete/swap either way, so I can't see anything better than simply copying each files you do want over the one you don't, which it sounds like you're already doing.