13 августа 2017 г.

Restoring added/modified dates on Firefox bookmarks after Firefox Sync messes them up

I added a new Firefox to my Firefox Sync account, it downloaded the bookmarks, but the added and modified dates were reset to the timestamp of when the sync was performed. Luckily, I had a backup of my places.sqlite file from the original Firefox.

You will need to find where Firefox stores your profile folder on both devices.

WARNING. You need to be familiar with SQL and understand what you're doing.

  • Download a client to work with SQLite databases, e.g. DB Browser for SQLite
  • Close/quit Firefox, make sure the process is ended. Backup both of your places.sqlite files.
  • Open the new places.sqlite in the program and attach the old one. When/if it prompts you for an alias, choose "places_backup".
    This is required to update one database with the values from another database.
  • Run the following query:
    ;WITH a AS
        UPDATE moz_bookmarks
            dateAdded=(SELECT dateAdded FROM a WHERE guid=moz_bookmarks.guid),
            lastModified=(SELECT lastModified FROM a WHERE guid=moz_bookmarks.guid)
        WHERE (SELECT dateAdded FROM a WHERE guid=moz_bookmarks.guid) IS NOT NULL
  • Save the new places.sqlite file and move it to the profile folder of your new Firefox.

Unfortunately, the next time you run Firefox Sync, the modified dates may still be reset to that date of when you run the Sync. However, the added dates will stay.

You can preview what items are common by running the following query:
SELECT b.title,b.id,b2.id,b.guid,b2.guid FROM moz_bookmarks as b JOIN places_backup.moz_bookmarks b2 where b.guid=b2.guid;

Комментариев нет: