# Export Data: Workers

**URL:** <https://forum.pioreactor.com/t/export-data-workers/241>\
**Category:** API & Data Access\
**Created:** [March 1, 2024, 12:44pm UTC](https://forum.pioreactor.com/t/export-data-workers/241 "2024-03-01T12:44:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 1, 2024, 12:44pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/1 "2024-03-01T12:44:45Z")

</div>

Hi everyone,

I am trying to export the data on a worker pioreactor by creating an ´export\_data.sh´ file by following the instructions in **Export and import your data \> Export your data**. This works for leader pioreactors, however when it comes to workers, **lighttpd.service** and **huey.service** loading error emerges along side **No such command ‘backup\_database’** as shown in the error log below:

**Error Log:**  
+ sudo systemctl stop lighttpd.service  
**Failed to stop lighttpd.service: Unit lighttpd.service not loaded.**  
+ true  
+ sudo systemctl stop huey.service  
**Failed to stop huey.service: Unit huey.service not loaded.**  
+ true  
+ sqlite3 /home/pioreactor/.pioreactor/storage/pioreactor.sqlite ‘PRAGMA wal\_checkpoint;’  
0|-1|-1  
++ sqlite3 /home/pioreactor/.pioreactor/storage/pioreactor.sqlite ‘PRAGMA quick\_check;’  
+ DB\_CHECK=ok  
+ [[ok != \o\k]]  
+ pio run backup\_database --force  
Usage: pio run [OPTIONS] COMMAND [ARGS]…  
Try ‘pio run --help’ for help.

**Error: No such command ‘backup\_database’.**  
+ pio run backup\_database  
Usage: pio run [OPTIONS] COMMAND [ARGS]…  
Try ‘pio run --help’ for help.

Did anyone encountered this issue or am I missing a point I should have taken?

In advance, thanks for your help!

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 1, 2024, 4:47pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/2 "2024-03-01T16:47:11Z")

</div>

Hi @sharknaro,

This might be a problem in our docs. The `export_data.sh` script is normally only used on the leader to export the core Pioreactor database. The workers don’t have a database file.

However, I’m guessing you are interested in exporting the _calibrations_ from the workers? This is possible using a different method - but now that I think about it, it should by as simple a script, too. Let me write one and I’ll share here soon.

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 1, 2024, 5:20pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/3 "2024-03-01T17:20:06Z")

</div>

Hi Cameron!

Yes, I want to change the cluster of the worker so I have to flash the SD card and I did not wanted to loose the calibration as it is going to be the same pioreactor just in a different cluster.

In the docs, I can see that the 5th step says to fo this for the workers for getting the calibration data, hence I tried ro implement the provided script.

Looking forward to hear from you. Thanks for your response and time!

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 1, 2024, 5:28pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/4 "2024-03-01T17:28:57Z")

</div>

> Yes, I want to change the cluster of the worker so I have to flash the SD card and I did not wanted to loose the calibration as it is going to be the same pioreactor just in a different cluster.

You don’t need to re-flash to change the worker’s cluster. The other cluster’s leader only needs to add the worker to its cluster (using the leader’s UI, or on the leader’s command line with `pio add-pioreactor <workername>`.

Does that solve your problem, or do you still want a worker export script?

* * *

EDIT: if you do this, also remove the worker from the original cluster by _deleting_ it’s associated line in the config.ini:

```auto
[cluster.inventory]
workername=1
originalleader=1
...

```

to

```auto
[cluster.inventory]
originalleader=1
...

```

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 1, 2024, 7:12pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/5 "2024-03-01T19:12:40Z")

</div>

> [@CamDavidsonPilon](#):
>
> You don’t need to re-flash to change the worker’s cluster. The other cluster’s leader only needs to add the worker to its cluster (using the leader’s UI, or on the leader’s command line with `pio add-pioreactor <workername>`.

Considering the limited information I provided, I can understand your logic here. Thus, sorry for not being explicit. In my case, I have two clusters next to each other with different SSIDs (lets call them c1 and c2). Hence, for the worker from c1 to be recognize by the c2 leader, I need flash the card with the SSID and password of c2 leader, right? However, if I am wrong snd transferring the worker without flashing, I would appreciate if you can elaborate that Cameron!

> [@CamDavidsonPilon](#):
>
> EDIT: if you do this, also remove the worker from the original cluster by _deleting_ it’s associated line in the config.ini:

Yes, I was already planning to execute this step once I exported the data, but thank you for the advice Cameron!

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 1, 2024, 8:33pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/6 "2024-03-01T20:33:31Z")

</div>

> [@sharknaro](#):
>
> However, if I am wrong snd transferring the worker without flashing, I would appreciate if you can elaborate that Cameron!

There’s a way to change the connected network of a Pioreactor - not a problem. Here’s how:

1. SSH into the worker you wish to change

2. First, in case things go sour in the next step, copy-paste the output of the following onto your computer.

3. Note that after you enter the next command, **your SSH session be disconnected** from the Pioreactor (since the Pi is switching to a different network than you’re on). Enter:

4. That should be it - you should be able to connect to wifi `c2` and be able to connect to the worker again.

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 2, 2024, 10:57am UTC](https://forum.pioreactor.com/t/export-data-workers/241/7 "2024-03-02T10:57:30Z")

</div>

Thank you very much for the information Cameron, I was not aware of this possibility! I will try it as soon as possible.

Kind regards,  
Baris Kara

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 5, 2024, 3:35pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/8 "2024-03-05T15:35:57Z")

</div>

Hi again Cameron,

I have went through the steps you suggested and it works like a charm!.. until being added to the next cluster. Once in the next cluster, the I get an error syncing configs to pio2 etc.

Currently, I am trying to figure out the reason. However, if you know the potential cause and have free time your help will be appreciated!

In advance, thanks for the help!

EDIT: I tried to discover the workers by the command line ´pio discover-workers´. However, the pio2 did not get discovered by the leader of the new cluster

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 5, 2024, 3:39pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/9 "2024-03-05T15:39:22Z")

</div>

Hi @sharknaro, is pio2 the worker you just added to the new cluster? Is there an error that is displayed?

Adding Pioreactors is idempotent (i.e. you can do it over and over again without harm): you could try re-adding the worker and see if that resolves it, too.

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 5, 2024, 3:51pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/10 "2024-03-05T15:51:34Z")

</div>

> [@CamDavidsonPilon](#):
>
> is pio2 the worker you just added to the new cluster?

Yes, that is correct. I added pio2 and pio3

> [@CamDavidsonPilon](#):
>
> Is there an error that is displayed?

No error displayed, after the addition. However, when I changed the position of the pio2 from bottom to top in the config.ini cluster section. I got the error syncing configs.

> [@CamDavidsonPilon](#):
>
> try re-adding the worker

I am tyring to re-add the pioreactors, however, I assume because they are already added to the cluster, I get the **error not found on network after 195 secs**.

---

<div class="post-metadata">

**Author:** ![CamDavidsonPilon](https://forum.pioreactor.com/user_avatar/forum.pioreactor.com/camdavidsonpilon/32/3_2.png) [@CamDavidsonPilon](https://forum.pioreactor.com/u/CamDavidsonPilon)\
**Post date:** [March 5, 2024, 4:02pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/11 "2024-03-05T16:02:16Z")

</div>

hm hm hm, sounds like pio2 isn’t on the network…

Oh! I know. In step 3 above, when you added the wifi credentials, everything was fine and it connected to `c2`. However, during “add-pioreactor”, the worker will reboot. I am guessing upon starting up again, it reconnected to its _old_ network, `c1`. This is because, given two available wifi networks `c1` and `c2`, it will choose the one with higher priority (probably `c1`).

Can you check to see if `pio2` is back on `c1` (check with a `ping pio2.local` after reconnecting to `c1`)?

If so, SSH into it, and let’s reassign priority:

```auto
nmcli connection modify <wifi-ssid-of-c2> connection.autoconnect-priority 100

```

Then you can reboot pio2 (`sudo reboot`), and I _think_ that will get pio2 responsive to the new cluster.

---

<div class="post-metadata">

**Author:** ![sharknaro](https://forum.pioreactor.com/letter_avatar_proxy/v4/letter/s/4bbf92/32.png) [@sharknaro](https://forum.pioreactor.com/u/sharknaro)\
**Post date:** [March 5, 2024, 4:22pm UTC](https://forum.pioreactor.com/t/export-data-workers/241/12 "2024-03-05T16:22:58Z")

</div>

This was a shot at the bullseye!

> [@CamDavidsonPilon](#):
>
> Can you check to see if `pio2` is back on `c1` (check with a `ping pio2.local` after reconnecting to `c1`)?

When I SSH to the leader of the old cluster and typed `ping pio2.local` I received a series of lines indicating successful replies along with information about the round-trip time. So you were correct.

> [@CamDavidsonPilon](#):
>
> If so, SSH into it, and let’s reassign priority:
> 
> ```auto
> nmcli connection modify <wifi-ssid-of-c2> connection.autoconnect-priority 100
> 
> ```
> 
> Then you can reboot pio2 (`sudo reboot`), and I _think_ that will get pio2 responsive to the new cluster.

After this step, pioreactor was synchronized with the config.ini of the new cluster.

Thank you very much Cameron!

SMALL DETAIL: Remember to include `sudo` to have right privilege, i.e.:

```auto
sudo nmcli connection modify <wifi-ssid-of-c2> connection.autoconnect-priority 100

```
