Skip to content

Instantly share code, notes, and snippets.

@kearfy
Last active April 13, 2023 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kearfy/adb0baa6476bdda744cb71605d0fc997 to your computer and use it in GitHub Desktop.
Save kearfy/adb0baa6476bdda744cb71605d0fc997 to your computer and use it in GitHub Desktop.
Upgrade SurrealDB from beta-8 to beta-9 for docker users (unofficial, rough example)

Original source can be found here: https://discord.com/channels/902568124350599239/970338835990974484/1096046227528888340 This gist is a rough example on how to approach this migration in case you're using docker

Author nickmenow, careerlister

Guide to update docker running SurrealDB beta8 to beta9

Starting from a logged in prompt of your computer, EC2 instance, Virtual Machine or box:

  1. Follow the guide to download on your operating system the correct extra beta-8 release found here => https://surrealdb.com/docs/installation/upgrading/beta8-to-beta9 Unarchive it to a safe location - perhaps in a new folder. My example is in folder with path /home/ubuntu/beta8_extra

  2. Go to docker.com and pull down the latest, nightly or 1.0.0-beta.9 image found here => https://hub.docker.com/r/surrealdb/surrealdb/tags

  3. run sudo docker images in your instance and locate the IMAGE ID of the image you just pulled. In this case the nightly I am working on now is : e2a7220adbfa

  4. Modify your docker-compose.yml (or similar) file to add another container running surrealdb with something similar. Keep in mind that your original yml file could be slightly different but make sure to pay attention to the container name, image id, ports and the volumes as each need to be unique from the original container. Save the file.

services:
  surrealdb:
    # BETA-8 Nightly
    image: f362651a2f2a
    restart: always
    command: start --log warn --user root --pass root file:/data/database.db
    ports:
      - 80:8000
    volumes:
      - ./data:/data
  surrealdb9:
    # BETA-9 Nightly
    image: e2a7220adbfa
    restart: always
    command: start --log warn --user root --pass root file:/data/database.db
    ports:
      - 8888:8000
    volumes:
      - ./data_9:/data
  1. run sudo docker compose up -d Docker should make the changes, add the container and start it on port 8888.

  2. Test it out by logging into the new running db on port 8888 surreal sql -c http://localhost:8888 --user root --pass root --ns test --db test --pretty Then run a query like INFO FOR DB to get the info for that db. (EC2 folks need to update the securitygroup to open port 8888)

  3. Make an export of the data from beta8 (using the port from the yml file) /home/ubuntu/beta8_extra/surreal export --conn http://localhost:80 --user root --pass root --ns production --db production "beta8backup/production-bak-$(date +"%Y_%m_%d_%I_%M_%p").surql" Change the NS and DB for each NS and DB that you have and modify the surql file name to what you need it to be.

  4. Import the export using the beta9 port => surreal import --conn http://localhost:8888 --user root --pass root --ns production --db production backup/production-bak-2023_04_13_12_06_PM.surql

  5. Test it using local surreal sql -c http://localhost:8888 --user root --pass root --ns production --db production --pretty and query INFO FOR DB. If all is good to go repeat for each NS and each DB in each NS.

  6. You can now switch the ports in your docker-compose.yml file if you'd like so that your beta9 data is now your main database. Make sure to run sudo docker compose up -d After your changes are complete.

  7. Help someone else on the SurrealDB discord and/or thank someone in the community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment