Skip to content

Instantly share code, notes, and snippets.

@ShadowJonathan
Created January 24, 2022 14:16
Show Gist options
  • Save ShadowJonathan/86edf119062f4ba0f861ad9de6e3c86c to your computer and use it in GitHub Desktop.
Save ShadowJonathan/86edf119062f4ba0f861ad9de6e3c86c to your computer and use it in GitHub Desktop.
`conduit_migrate` WIP docs

Use the following to install or update conduit_migrate;

cargo install --locked --git https://github.com/shadowjonathan/conduit_toolbox conduit_migrate

This'll place it in ~/.cargo/bin, make sure you have this on your $PATH, see rustup documentation for more info.

You can choose a origin database format and a destination database format, the current ones are;

  • heed
  • sqlite
  • sled
  • rocks (RocksDB)

To migrate a database, please do the following;

  • Make sure your server is off, a conversion will be likely corrupted if you do it while it is running.
  1. Move the original database folder to a different place, a folder rename would do.
  • You can technically convert databases in-place, but it is not recommended as it'll mix and match the files.
  • Do not convert in-place when using the same origin and destination database formats, you will almost certainly corrupt your data
  1. Create a new folder. (With the original name would be preferred, as you then dont have to make any config edits)
  2. Do the following command, and replace the bits in {} curly brackets; conduit_migrate -s {old_directory} -f {old_database_format} -d {new_directory} -t {new_database_format}
  • old_directory: the full path of the old directory (/mnt/data/conduit_db)
  • old_database_format: the name of the old databse format (sqlite, heed, etc.)
  • new_directory: the full path of the new directory
  • new_database_format: the name of the new database format (sqlite, rocks, etc.)
  • Don't put these inside the curly brackets, replace the whole part with curly brackets with the information.
  • If a full path has a space, put it in quotation marks ("/mnt/data/Matrix Server Stuff/conduit_db")
  • This command will show a bunch of numbers scrolling up rapidly, this is expected.
    • If the scrolling stops, make sure you have a prompt again (jonathan@jon:/mnt/data/conduit.dev/conduit_db$ _) before going further, it might just be slow.
    • Make sure it has not ended with Killed or Terminated, this means the process has failed.
      • Remove the new directory, recreate it, and try again. (Contact the conduit room if this keeps happening)
    • If it failed and muttered something about "not enough space", you need to increase your free space before you can convert it.
  1. Move the media subfolder from the old folder to the new one.
  2. Do not delete the old folder until you're sure that the new server works fine, only come back to deleting it about a month down the line (if everything went alright), or just back it up somewhere else.

Permission Issues / "OS Error 13"

Make sure the permissions on your old folder and the new folder are the same;

  1. Do ls -l while cd'd inside your old folder.
  2. Note down the two names or numbers appearing before a long number in the file name;
jonathan@jon:/mnt/data/conduit.dev/conduit_db$ ls -l
total 368652
-rw-r--r-- 1 root 1002 377495552 Nov 27 15:20 conduit.db
             ^^^^ ^^^^
             these
  1. cd into the new folder, then use chown root:1002 -R ., replacing root and 1002 here with the first and second name/number you saw in ls -l.

If you see multiple names or numbers, or this doesn't seem to work, please ask in the conduit room.

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