Copy data from your webserver to mine

Hey Guys,
I hadn’t originally planned to set up my own webserver, but as I use the farmbot off grid and it is consuming a lot more data than my provider sells me for reasonable money, I had to set up my own server.

I did this

  • with a ZOTAC ZBOX CI327 NANO Barebone which can be powered from a 12V battery

  • with a sourcingmap® DC 12V (9V~18V) to 19V 5A 95W transformer and has enough power to meet the requirements, btw.

Now I need to transfer the plant data from your webserver to mine. Can this be done?
Can this be done with the “Export Account Data” Button? But how to import it again then?
Is there some kind of instruction for that? I am no expert with coding :frowning:

Nobody? Could you maybe help with that @RickCarlino?
I need to pass the data from you webserver to mine, otherwise I can’t go on with all the plants that are already planted…

@derletztename While we do have a way to export all data as JSON (see screenshot above from account settings page), we don’t have a bulk import feature at the moment. We do plan to implement such a feature in the future, but it has yet to be implemented.

Thanks for answering. And great that the export function is already implemented. But how do I import it?
I really need to copy the data to the new server. I guess the import can be done with linux console commands?
Could you maybe explain me which files go to where? Or if the import of the JSON file ist not possible yet, could you just send me the original files from you server, so I could copy them manually to mine?

could you use a raspberry pi zero? Its energy draw will be much lower and it only cost $5

That would be great @DavidHerrera, but as far as I understand RickCarlino here (https://github.com/FarmBot/Farmbot-Web-App/issues/870) they haven’t yet programmed for ARM and also need more RAM for the Server Web App to run smoothly.

@RickCarlino you mentioned there is no bulk import. Can I manually import the plant information for the farm designer somehow? I mean I can read the content of the json file, there must be a way to copy parts of it onto my own server and therefore have a way around planting all the plant again.

@derletztename

import can be done with linux console commands?

There are no linux command line tools built for this purpose. If a developer is willing to write such a tool, I would gladly provide a link to it in the README in the meantime while we work towards an account importer feature.

could you just send me the original files from you server?

This is already possible via the “export” feature shown above. In the case of image files, they are accessible via the attachment_url property of the image records that are exported. The data from the plants from the farm designer are available with the *.json file. You will find them under the "points" property of the exported data.

Can I manually import the plant information for the farm designer somehow? I mean I can read the content of the json file, there must be a way to copy parts of it onto my own server and therefore have a way around planting all the plant again.

This is possible, but you will need to write this software yourself, as we have not had time to write the importer on our end yet. As far as I know, no one in the FarmBot development community has written a third party tool for this and there are no Linux command line tools that can do this out-of-the-box.

If you are willing to write the software yourself, you have a few options available (listed below).

I would like to reiterate that although it is possible, it is not a simple task and will require experimentation, as well as an understanding of SQL and a programming language. As stated previously, we do intend to add a user-friendly account importer in the future, but have not yet started work on such a feature due to time constraints.

Option 1: Use a Script + API requests

You could use a scripting language of your choice (Ruby, Lua, Python, etc) to parse the JSON and iterate over the data. You would then perform an API POST request to your personal server for each of the records.

You would need to change any / all of the fields that contain _id attributes, since the ID of a resource is only valid on the public server.

This will require knowledge of a scripting language, an HTTP client in the language of your choice and the appropriate API endpoints.

Example API requests can be found here

Option 2: Create a Rails Runner Script ("rails r my_script.rb")

Since it’s a private server, you can execute arbitrary Ruby code. You could, in theory write a Ruby script that parses the JSON and directly inserts the data via standard Rails ActiveRecord commands (you will need to scrub the primary / foreign keys. I can’t help here because I have not tried this)

Option 3: Raw SQL

Using the scripting language of your choice and a SQL driver, connect to the database, parse the JSON file and perform INSERT statements. Again, this will require you to manually translate the foreign / primary keys of relations. It will require knowledge of the scripting language SQL and the SQL driver of choice.