You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With this commands I was able to recreate a database and now activity watch starts. In case of this issue you have aw-qt reporting an error, if you press restart server aw-qt crashes...
With the more details button you see the error on peewee about the malformed database, so you need to do those commands and restart aw-qt.
But this does not actually recover the old database right, only initializes a new one?
To just get a new one, you can just delete the database while aw-server is not running and a new one will automatically be created next time aw-server starts.
EDIT: This comment technically relates to aw-server-rust, but it's about advice for restoring databases, so.
Note - if you end up restoring your database this way, you may then encounter a problem where the rust server (maybe the python one too, haven't checked) falsely considers it to be v1, tries to upgrade it, and crashes with an error message like this one:
[2023-07-29 02:33:35][INFO][aw_datastore::datastore]: Upgrading database to v2, adding data field to buckets
thread '<unnamed>' panicked at 'Failed to upgrade database when adding data field to buckets: SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("duplicate column name: data"))', aw-datastore/src/datastore.rs:126:6
This is because the version is determined by the user version pragma, which seems to not be copied by .dump. Manually setting that pragma to the right one (whatever the original database had, but currently the latest is 4) fixes it.
The startup crash @RundownRhino described is fixed in aw-server-rust master by ActivityWatch/aw-server-rust#776, which ships in the next release. sqlite3 .dump doesn't carry over PRAGMA user_version, so a restored DB reported version 0 and the server re-ran every migration on it, panicking with a duplicate data column. The server now infers the version from the schema and logs a warning.
On an older release, run PRAGMA user_version; on the original DB before dumping, then set that same value on the restored file (sqlite3 restored.db 'PRAGMA user_version = N;'). For a badly corrupted file, sqlite3 old.db .recover usually salvages more than .dump.
The startup-crash variant described by @RundownRhino (restored DB with user_version 0 causing the server to re-run all migrations and panic) is fixed in ActivityWatch/aw-server-rust#776 (fix(datastore): infer schema version when a restored DB has user_version 0, merged 2026-10-10). The fix ships in aw-android as of the latest build(deps): updated aw-server-rust bump. Recovery documentation has also been updated. This issue is ready to close.
Activity
johan-bjareholt commentedon Dec 30, 2021
But this does not actually recover the old database right, only initializes a new one?
To just get a new one, you can just delete the database while aw-server is not running and a new one will automatically be created next time aw-server starts.
Mte90 commentedon Dec 30, 2021
I was able to recover the majority of the database in this way.
The sqlite db was 570mb, after the dump and creating a new one it was 517mb.
I don't know what I lost but at least I didn't had to reset everything.
johan-bjareholt commentedon Dec 30, 2021
That's very interesting, thanks for the tip!
This should probably be documented in the official documentation somewhere.
RundownRhino commentedon Jul 28, 2023
EDIT: This comment technically relates to aw-server-rust, but it's about advice for restoring databases, so.
Note - if you end up restoring your database this way, you may then encounter a problem where the rust server (maybe the python one too, haven't checked) falsely considers it to be v1, tries to upgrade it, and crashes with an error message like this one:
This is because the version is determined by the user version pragma, which seems to not be copied by
.dump. Manually setting that pragma to the right one (whatever the original database had, but currently the latest is 4) fixes it.fix(datastore): infer schema version when a restored DB has user_vers…
fix(datastore): infer schema version when a restored DB has user_vers…
fix(datastore): infer schema version when a restored DB has user_vers…
TimeToBuildBob commentedon Oct 10, 2026
The startup crash @RundownRhino described is fixed in aw-server-rust master by ActivityWatch/aw-server-rust#776, which ships in the next release.
sqlite3 .dumpdoesn't carry overPRAGMA user_version, so a restored DB reported version 0 and the server re-ran every migration on it, panicking with a duplicatedatacolumn. The server now infers the version from the schema and logs a warning.On an older release, run
PRAGMA user_version;on the original DB before dumping, then set that same value on the restored file (sqlite3 restored.db 'PRAGMA user_version = N;'). For a badly corrupted file,sqlite3 old.db .recoverusually salvages more than.dump.TimeToBuildBob commentedon Oct 11, 2026
The startup-crash variant described by @RundownRhino (restored DB with
user_version 0causing the server to re-run all migrations and panic) is fixed in ActivityWatch/aw-server-rust#776 (fix(datastore): infer schema version when a restored DB has user_version 0, merged 2026-10-10). The fix ships in aw-android as of the latestbuild(deps): updated aw-server-rustbump. Recovery documentation has also been updated. This issue is ready to close.