Initial backup stuck at 100%

I ended up killing Duplicati since it seemed unlikely to finish. I tested running ANALYZE on the database and the query went from hanging indefinitely to completing in seconds. Doing this changed the query plan from SCAN to SEARCH.

I see that Duplicati is already using PRAGMA optimize:

Maybe this needs the chance to run earlier?

After restarting Duplicati, it verified successfully and did not need to reupload any data.