# Sync v2 testing

**URL:** <https://forum.atuin.sh/t/sync-v2-testing/124>\
**Category:** General\
**Created:** [February 5, 2024, 9:45am UTC](https://forum.atuin.sh/t/sync-v2-testing/124 "2024-02-05T09:45:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 5, 2024, 9:45am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/1 "2024-02-05T09:45:39Z")

</div>

# As of v18, sync v2 is now available to opt-in

Hey! I think we’re finally ready 🙂

I’ve mentioned it a whole bunch over the past few months, but I’ve been working on replacing Atuin’s sync with something much more flexible, resilient, and performance (both in terms of time, _and_ network usage).

You may have seen references to “records” in Atuin’s sync output. These are generic syncable-things. Currently used by the kv store, and now by history too!

## How to use

All machines must run the same version of sync - so if you enable record sync on one machine, but not another, they will not sync with each other.

### Setup

1. Ensure you’re running at least atuin v18
2. Add this to your `~/.config/atuin/config.toml`:

```auto
[sync]
records = true

```

1. Run `atuin sync`.
2. If prompted by (3), run `atuin history init-store`. This will copy all of your history from `history.db` into `records.db`. Then run `atuin sync` again. This is only required when you’ve used the old sync, to ensure sync v2 is all caught up with old data.

At any time, run `atuin store status` to see what’s going on with your stores.

## More details

`records.db` store an encrypted (on disk) “log” of records. For history, this is `Create(History),` or `Delete(HistoryId)`. This is then “built” into `history.db`, which turns it into a searchable format that can be used by the history TUI, search, etc. Records works great for sync and long term storage, history is great for actual usage. This makes things much simpler + more flexible.

You can trigger a “rebuild” manually with

```auto
atuin store rebuild history

```

One issue that has appeared a bunch with the “old” sync is when users have mixed keys. Maybe they paste it wrong, forget it, whatever. Their remote account ends up with history encrypted with a variety of keys, which causes sync to fail. The only solution here was to delete your account and start afresh.

This worked fine, as history was store unencrypted locally.

Now that we are storing it encrypted locally and syncing from there, it’s a little more complicated.

The new sync provides new operations to both check the state of the local store, and to recovery. I’ll provide more details on those later!

---

<div class="post-metadata">

**Author:** ![lilydjwg](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/lilydjwg/32/64_2.png) [@lilydjwg](https://forum.atuin.sh/u/lilydjwg)\
**Post date:** [February 6, 2024, 3:11am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/2 "2024-02-06T03:11:32Z")

</div>

I’d like to test, but I have a few questions.

My history has not been fully synced from the start (maybe because they already have similar local histories before I start syncing). Is there anything special I should do for this test? Will this v2 solve the desync for me?

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [February 6, 2024, 10:03am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/3 "2024-02-06T10:03:16Z")

</div>

Hey. I will try to set it up later today. Is there anything special you would like us to tests? Any test cases to try and experiment with?

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 6, 2024, 10:28am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/4 "2024-02-06T10:28:18Z")

</div>

> [@lilydjwg](#):
>
> Is there anything special I should do for this test?

Nothing special! I’m hoping it will “just work”, once it’s gotten going

> [@lilydjwg](#):
>
> Will this v2 solve the desync for me?

Without knowing more about the reason it’s not syncing for you atm I cannot say for sure, but it’s very likely to solve the problem. If it doesn’t, I’d definitely like to have a look and figure out why

Thank you for testing!

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 6, 2024, 10:33am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/5 "2024-02-06T10:33:03Z")

</div>

Thank you!

Nothing in particular - honestly just building some confidence that the sync will work without issues, end to end, on a variety of systems and setups.

If you and @lilydjwg are able to share

1. How many machines you’re syncing
2. The output of `atuin store status`

Then that would be extra helpful 🙂 Just to check that it’s working optimally internally too.

---

<div class="post-metadata">

**Author:** ![lilydjwg](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/lilydjwg/32/64_2.png) [@lilydjwg](https://forum.atuin.sh/u/lilydjwg)\
**Post date:** [February 6, 2024, 3:13pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/6 "2024-02-06T15:13:08Z")

</div>

I’m syncing two machines.

```auto
host: 018cb9fc-a161-7f64-ae47-b38a5db0d123
	store: history
		idx: 59241
		first: 018ce771-5dc4-7d26-8abe-a2fdf9d2ef38
			created: 2024-01-08 5:00:15.684612767 +00:00:00
		last: 018d7ef9-7429-7c18-a679-cd3fd19f0c01
			created: 2024-02-06 15:11:33.929096321 +00:00:00

host: 018ccdf9-4437-713e-85e6-fae9d64c6b6f <- CURRENT HOST
	store: history
		idx: 57030
		first: 018cf369-0d6c-7837-b3f9-5bfeb908687a
			created: 2024-01-10 12:46:37.420039931 +00:00:00
		last: 018d7ef9-903d-79a6-a0c7-2d4283a72ec6
			created: 2024-02-06 15:11:41.117508519 +00:00:00

```

```auto
host: 018cb9fc-a161-7f64-ae47-b38a5db0d123 <- CURRENT HOST
        store: history
                idx: 59240
                first: 018ce771-5dc4-7d26-8abe-a2fdf9d2ef38
                        created: 2024-01-08 5:00:15.684612767 +00:00:00
                last: 018d7ef9-5a4a-7cae-8195-23e9392b2576
                        created: 2024-02-06 15:11:27.306777929 +00:00:00

host: 018ccdf9-4437-713e-85e6-fae9d64c6b6f
        store: history
                idx: 57029
                first: 018cf369-0d6c-7837-b3f9-5bfeb908687a
                        created: 2024-01-10 12:46:37.420039931 +00:00:00
                last: 018d7edc-4878-7ff9-85af-04d97def1e64
                        created: 2024-02-06 14:39:42.200366345 +00:00:00

```

They seem to be fully synced now!

---

<div class="post-metadata">

**Author:** ![lilydjwg](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/lilydjwg/32/64_2.png) [@lilydjwg](https://forum.atuin.sh/u/lilydjwg)\
**Post date:** [February 6, 2024, 3:32pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/7 "2024-02-06T15:32:07Z")

</div>

I have another set of atuin consisting of four instances , and three of them has run into trouble:

```auto
$ atuin history init-store
Importing all history.db data into records.db
Fetching history from old database
Fetching history already in store
Error: attempting to decrypt with incorrect key. currently using AAA, expecting BBB

Location:
    atuin-client/src/record/encryption.rs:132:9

```

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 6, 2024, 3:39pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/8 "2024-02-06T15:39:01Z")

</div>

Ah, ok. At some point, those machines were probably running either

1. not being logged in, so with some generated key
2. with the incorrect key specified

There’s a few workarounds. First, we can check that this is definitely the case (mixed keys in store) with

```auto
atuin store verify

```

If that reports mixed keys, you can run

```auto
atuin store purge

```

To delete records from the store that we no longer have the key for. Those are essentially noise, anyway.

Let me know if this machine has been syncing prior to this, and we can sort the remote storage out too.

(tldr of my life is that e2e encryption and key management makes things _really_ annoying sometimes 😂)

---

<div class="post-metadata">

**Author:** ![lilydjwg](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/lilydjwg/32/64_2.png) [@lilydjwg](https://forum.atuin.sh/u/lilydjwg)\
**Post date:** [February 6, 2024, 3:50pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/9 "2024-02-06T15:50:41Z")

</div>

> [@ellie](#):
>
> not being logged in, so with some generated key

This should be the case. I might have imported history before logging in.

The issue has been resolved after running `atuin store purge`, thanks!

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [February 6, 2024, 6:47pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/10 "2024-02-06T18:47:24Z")

</div>

I use mainly one machine (the first; history backed-up on the server) and synchronize with experimental VM (second machine). Everything seems to work as expected. It runs beautifully.

```auto
host: 018a79f8-ed46-7d93-965d-c241a1aa624e <- CURRENT HOST
        store: history
                idx: 21685
                first: 018d7f64-8cde-7f62-b1e6-b187ec0173de
                        created: 2024-02-06 17:08:32.606837568 +00:00:00
                last: 018d7fba-ddbc-7b8f-8413-e222ef77b7f9
                        created: 2024-02-06 18:42:49.404281554 +00:00:00

host: 018d44f9-b2af-7525-89a0-0974a2c6491b
        store: history
                idx: 47
                first: 018d7faf-53ce-78f3-afd7-f6aca20caf55
                        created: 2024-02-06 18:30:13.198771468 +00:00:00
                last: 018d7fba-b9d6-72fb-b37a-7cfbc91ccba2
                        created: 2024-02-06 18:42:40.214356124 +00:00:00

```

```auto
host: 018a79f8-ed46-7d93-965d-c241a1aa624e
        store: history
                idx: 21684
                first: 018d7f64-8cde-7f62-b1e6-b187ec0173de
                        created: 2024-02-06 17:08:32.606837568 +00:00:00
                last: 018d7fb8-e606-70d7-9e64-75482f58a085
                        created: 2024-02-06 18:40:40.454934974 +00:00:00

host: 018d44f9-b2af-7525-89a0-0974a2c6491b <- CURRENT HOST
        store: history
                idx: 46
                first: 018d7faf-53ce-78f3-afd7-f6aca20caf55
                        created: 2024-02-06 18:30:13.198771468 +00:00:00
                last: 018d7fba-b1bf-7837-9777-840c702b01ba
                        created: 2024-02-06 18:42:38.143468074 +00:00:00

```

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 7, 2024, 8:23am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/11 "2024-02-07T08:23:37Z")

</div>

> [@Adda](#):
>
> Everything seems to work expected. It runs beautifully.

Glad to hear it! ☺ thanks for testing

---

<div class="post-metadata">

**Author:** ![scudderfish](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/scudderfish/32/133_2.png) [@scudderfish](https://forum.atuin.sh/u/scudderfish)\
**Post date:** [February 10, 2024, 4:40pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/12 "2024-02-10T16:40:48Z")

</div>

Doing this seems to have sorted out my laptop and desktop not sharing history correctly. Thanks!

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 12, 2024, 9:02am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/13 "2024-02-12T09:02:12Z")

</div>

Great! Glad to hear that. Welcome to the forum 😊

---

<div class="post-metadata">

**Author:** ![dotsam](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/dotsam/32/150_2.png) [@dotsam](https://forum.atuin.sh/u/dotsam)\
**Post date:** [February 12, 2024, 8:11pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/14 "2024-02-12T20:11:45Z")

</div>

I’ve had issues for a while now with three hosts being out of sync, but upgrading them all to 18.0.1 and switching to sync v2 has everything happy now, all hosts have all records from all other hosts. I’ll close my [GitHub issue](https://github.com/atuinsh/atuin/issues/989) for this now too.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 13, 2024, 8:45am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/15 "2024-02-13T08:45:53Z")

</div>

Awesome! Glad that sorted it all out for you 😊

---

<div class="post-metadata">

**Author:** ![fumnanya](https://forum-cdn.atuin.sh/letter_avatar_proxy/v4/letter/f/5f8ce5/32.png) [@fumnanya](https://forum.atuin.sh/u/fumnanya)\
**Post date:** [February 14, 2024, 8:01am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/16 "2024-02-14T08:01:01Z")

</div>

saw Ellie’s post on mastodon and decided to give it a try…the migration process is really smooth and the instructions worked fine…i dont have multiple machines so it’s just this one for now

the timeout was a but small though, i had to move my laptop to basically in front of the router (but that’s probs just shitty internet)

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 14, 2024, 10:54am UTC](https://forum.atuin.sh/t/sync-v2-testing/124/17 "2024-02-14T10:54:20Z")

</div>

> [@fumnanya](#):
>
> the migration process is really smooth and the instructions worked fine…i dont have multiple machines so it’s just this one for now

Glad to hear it went smoothly! Curious as to the biggest reason you want to sync, if you’re using one machine - is it for backups? (totally valid either way)

> [@fumnanya](#):
>
> the timeout was a but small though, i had to move my laptop to basically in front of the router (but that’s probs just shitty internet)

What sort of error were you getting? Also was this a self hosted server or the public one?

---

<div class="post-metadata">

**Author:** ![fumnanya](https://forum-cdn.atuin.sh/letter_avatar_proxy/v4/letter/f/5f8ce5/32.png) [@fumnanya](https://forum.atuin.sh/u/fumnanya)\
**Post date:** [February 14, 2024, 12:54pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/18 "2024-02-14T12:54:31Z")

</div>

> [@ellie](#):
>
> Glad to hear it went smoothly! Curious as to the biggest reason you want to sync, if you’re using one machine - is it for backups? (totally valid either way)

yeahh the backups are the main thing…and for eventually when i move over from this  
also the ui looks greattttttt 🤩  
(and i get to see history entries from other currently opened shells – normally, i think my zsh `.histfile` only gets written to when i close the shell, so if there’s multiple sessions open, you can’t see something you just did somewhere else)

> [@ellie](#):
>
> What sort of error were you getting? Also was this a self hosted server or the public one?

the public one, and it was something along the lines of “something [api.atuin.sh](http://api.atuin.sh) timeout reached”, but it was happening like only after 3 seconds

like i said, probably terrible wifi…i was just surprised it didn’t try for longer

---

<div class="post-metadata">

**Author:** ![Adda](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/adda/32/36_2.png) [@Adda](https://forum.atuin.sh/u/Adda)\
**Post date:** [February 14, 2024, 1:02pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/19 "2024-02-14T13:02:45Z")

</div>

> [@ellie](#):
>
> Curious as to the biggest reason you want to sync, if you’re using one machine - is it for backups? (totally valid either way)

I found out that using Atuin to sync history between the host machine and numerous VMs is also a great use for the sync feature, even if it is still just to share history on a single machine, technically. It helps immensely.

---

<div class="post-metadata">

**Author:** ![ellie](https://forum-cdn.atuin.sh/user_avatar/forum.atuin.sh/ellie/32/564_2.png) [@ellie](https://forum.atuin.sh/u/ellie)\
**Post date:** [February 14, 2024, 2:03pm UTC](https://forum.atuin.sh/t/sync-v2-testing/124/20 "2024-02-14T14:03:28Z")

</div>

> [@fumnanya](#):
>
> yeahh the backups are the main thing…and for eventually when i move over from this  
> also the ui looks greattttttt 🤩

Makes sense! Haha glad to hear it 😃

> [@fumnanya](#):
>
> but it was happening like only after 3 seconds

We have some timeout config here, if this happens often for you

[https://docs.atuin.sh/configuration/config/#network\_timeout](https://docs.atuin.sh/configuration/config/#network_timeout)

> [@Adda](#):
>
> I found out that using Atuin to sync history between the host machine and numerous VMs is also a great use for the sync feature

I’ve heard this a few times! I never thought of that with the initial development, but it’s awesome that Atuin helps there too. Roughly how many VMs have you used it with?

[Next page](https://forum.atuin.sh/t/sync-v2-testing/124.md?page=2)
