Skip to content

Migration from 0.x.x to 1.x.x

Alexander Staeding edited this page Jul 20, 2020 · 3 revisions

This guide is outdated and only applies for MSDataSync (not DataSync)

Follow these steps to migrate your existing data from version 0.x.x to 1.x.x

Config

  1. Migrate MongoDB first using steps below
  2. Make sure server is off
  3. Rename config file msdatasync.conf to msdatasync_old.conf
  4. Put 1.x.x jar into mods or plugins folder and remove the old version
  5. Start server
  6. Open both config files msdatasync.conf (the newly generated one) and msdatasync_old.conf in a text editor
  7. Copy settings over where appropriate (structure changed slightly) and save file
  8. Run /sync reload or restart server
  9. Done!

MongoDB

Run the following commands in your console

(while your server is off, and before you turn on the server with the new version):

  1. mongo -u <user> -p <password> <hostname>/<database>

    (e.g. mongo -u dbuser -p abadpassword 1.2.3.4/msdatasync_server1)

    Should look something like this after you run it:

     MongoDB shell version v4.0.3
     connecting to: mongodb://1.2.3.4:27017/msdatasync_server1
     Implicit session: session { "id" : UUID("...") }
     MongoDB server version: 4.0.12
    
  2. use <database>

    (e.g. use msdatasync_server1)

    Should look something like this after you run it:

     switched to db msdatasync_server1
    
  3. db.members.updateMany({}, {$set: {className: "rocks.milspecsg.msdatasync.model.core.member.MongoMember"}});

  4. db.snapshots.updateMany({}, {$set: {className: "rocks.milspecsg.msdatasync.model.core.snapshot.MongoSnapshot"}});

  5. db.snapshots.updateMany({}, {$set: { "itemStacks.$[].className": "rocks.milspecsg.msdatasync.model.core.serializeditemstack.MongoSerializedItemStack"}});

That's it!

To confirm that it worked, run db.members.find({}).limit(1).pretty();. The result should look something like this:

{
    "_id" : ObjectId("5dd713aa36a7d03b572a3dc5"),
    "className" : "rocks.milspecsg.msdatasync.model.core.member.MongoMember",
    "userUUID" : BinData(3,"cFlfWZo7VQ7J1TNcJBxerA=="),
    "updatedUtc" : ISODate("2019-11-21T22:46:02.569Z"),
    "snapshotIds" : [
            ObjectId("5de83bf7b19d425d2a9053db"),
            ObjectId("5debc84f6edc07657d51709c"),
            ObjectId("5ded54cf4ac8ed4c0250467a"),
            ObjectId("5df050378597da280a8de7cc"),
            ObjectId("5df051258597da280a8de7d3")
    ]
}

And for snapshots, run db.snapshots.find({}).limit(1).pretty();, which should look something like this:

{
    "_id" : ObjectId("5de81bcaeddf697a65346e4a"),
    "className" : "rocks.milspecsg.msdatasync.model.core.snapshot.MongoSnapshot",
    "name" : "Auto",
    "server" : "spawn",
    "modulesUsed" : [
            "msdatasync:experience",
            "msdatasync:gameMode",
            "msdatasync:health",
            "msdatasync:hunger",
            "msdatasync:inventory"
    ],
    "keys" : {
            "saturation" : 5,
            "total_experience" : 0,
            "game_mode" : "SURVIVAL",
            "health" : 20,
            "food_level" : 20
    },
    "itemStacks" : [
            {
                    "className" : "rocks.milspecsg.msdatasync.model.core.serializeditemstack.MongoSerializedItemStack",
                    "properties" : {
                            "ContentVersion" : 1,
                            "ItemType" : "openblocks:info_book",
                            "UnsafeDamage" : 0,
                            "Count" : 1
                    }
            },
    ... (not including all 41)
    ]
}

(Make sure the property className matches in all three cases. If it doesn't, repeat steps 3-5)