Choosing a database¶
We recommend ClickHouse. It gives Spyglass the fastest rollbacks and keeps the most history in the least disk space. In a 2-million-block test, a rollback on ClickHouse took about 5 seconds and the history took about 11 MiB of disk. CoreProtect on MySQL took about 12 seconds and 180 MiB. Set it up below.
Spyglass starts on SQLite, a file in the plugin folder, so it works the moment you install it. That's fine for trying Spyglass or for a small server, and you can move your history to ClickHouse later with one command.
| Backend | Setting | Good for |
|---|---|---|
| ClickHouse (recommended) | "clickhouse" |
Any server that can run it. The fastest rollbacks and the smallest storage. |
| SQLite | "sqlite" |
The default. Nothing to set up; good for trying Spyglass or a small server. |
| MariaDB / MySQL | "mariadb" or "mysql" |
Hosts that already run one. |
| MongoDB | "mongo" |
Servers already running MongoDB. |
Spyglass creates its own database and tables on first start. You only need a database user that's allowed to create them.
Setting up ClickHouse¶
-
Run a ClickHouse server, on the same machine as your Minecraft server or anywhere Spyglass can reach. Spyglass is tested with ClickHouse 24.8. With Docker:
docker run -d --name clickhouse --restart unless-stopped \ -p 127.0.0.1:8123:8123 \ --ulimit nofile=262144:262144 \ -e CLICKHOUSE_PASSWORD=change-me \ -v clickhouse-data:/var/lib/clickhouse \ clickhouse/clickhouse-server:24.8Without Docker, follow ClickHouse's install guide.
-
Point Spyglass at it in
config.conf: -
Restart the server. Spyglass creates its database and table, and the console shows
backend = CLICKHOUSE.
Already have history in SQLite? Fill in the clickhouse block but leave backend alone, run /sg migrate clickhouse, then switch backend and restart. See Moving to another database.
Settings¶
Only the block for the backend you chose is read. These are the defaults for each:
How long records are kept¶
Records are deleted after 26 weeks by default. Change it with storage.retention, or per event type. See Configuration.
Moving to another database¶
/sg migrate <backend> copies every record from the database you're using into another one. History is never lost when you switch.
- Fill in the new backend's block in
config.conf. Leavebackendas it is for now. - Run
/sg migrate <sqlite|mariadb|mongo|clickhouse>and wait for "Migration complete". - Change
database.backendto the new one and restart.
Good to know:
- Needs the
spyglass.migratepermission. - If the target already has records, add
--confirm. Re-running a migration skips records that are already there, except on MongoDB, where it's refused. - Records written while the copy runs might not be copied. Migrate during a quiet time and switch right after.
- Only one migration runs at a time, and not while an import is running.
- Undo history, wand state, salvage and saved player inventories aren't copied. They start fresh on the new database.