# Storage & Sync

> **Info:**
Storage has no screen in the in-game editor. Every option on this page lives under `storage` in config.yml.

## Storage

Where holograms, each player's pages and hidden holograms, and the values of tracked leaderboards are kept. Animations, translations, images and config.yml always stay files.

| Key | Default | Description |
| --- | ------- | ----------- |
| `type` | `yaml` | `yaml`, `sqlite`, `mysql`, `mariadb` or `postgresql`. Anything else counts as `yaml`. |
| `address` | `localhost` | The database host. |
| `port` | `3306` | The database port. PostgreSQL usually uses `5432`. |
| `name` | `phoenixholograms` | The database name. |
| `username` | `root` | The database user. |
| `password` | `password` | The database password. |
| `table-prefix` | `pholo` | Put in front of every table name. |
| `pool-size` | `6` | The most connections the plugin keeps open. |
| `jdbc-url-options` | empty | Extra options added to the JDBC url. |

`yaml` uses the holograms and data folders. `sqlite` uses one database file in the plugin folder and only reads `table-prefix`. `mysql`, `mariadb` and `postgresql` use a database server that several servers can share. The server downloads the PostgreSQL driver and the Redis client on the first start after an update and keeps them in its libraries folder, so that start needs internet access.

The type switches on `/pholo reload`. When the database cannot be reached the plugin keeps running on the YAML files until the next reload and logs the error in the console.

## Copying between storage types

`/pholo storage migrate <from> <to>` copies every hologram, each player's pages and hidden holograms, and the tracked leaderboard values from one storage type to another, for example `/pholo storage migrate yaml mysql` before turning on [sync](#cross-server-sync). Both sides use the connection settings above, and `yaml` uses the holograms and data folders. Holograms that already exist in the target are replaced by the copy; nothing is deleted from either side.

The copy runs in the background and reports how much it copied. The server keeps using its current storage: set `type` to the new one and run `/pholo reload` to switch. `/pholo storage status` shows the type in use. Both need `phoenixholograms.command.storage`.

When `<to>` is the storage the server uses right now, the copy overwrites its holograms with the source and can undo edits made since. The command then asks for `confirm` at the end, `/pholo storage migrate yaml mysql confirm`, and reloads the holograms from storage once the copy is done.

## Cross-Server Sync

Sync is only for several servers that share one MySQL, MariaDB or PostgreSQL database. A hologram created, edited or deleted on one server is reloaded on the others. Each server checks the database every `poll-interval` seconds. With Redis on, changes are pushed to the other servers at once and the checks pause while Redis is connected.

| Key | Default | Description |
| --- | ------- | ----------- |
| `sync.enabled` | `true` | Turns the sync on or off. |
| `sync.poll-interval` | `10` | Seconds between database checks, from 2 to 3600. |
| `sync.redis.enabled` | `false` | Pushes changes through Redis. |
| `sync.redis.host` | `localhost` | The Redis host. |
| `sync.redis.port` | `6379` | The Redis port. |
| `sync.redis.password` | empty | The Redis password. Leave empty for none. |
| `sync.redis.ssl` | `false` | Connects to Redis over SSL. |
| `sync.redis.channel` | `phoenixholograms` | Every server must use the same channel. |

When Redis drops, the servers go back to checking the database until it is back.

## Example

```yaml
storage:
  type: mysql
  address: db.example.com
  port: 3306
  name: phoenixholograms
  username: holograms
  password: change-me
  table-prefix: pholo
  pool-size: 6
  jdbc-url-options: ""
  sync:
    enabled: true
    poll-interval: 10
    redis:
      enabled: true
      host: redis.example.com
      port: 6379
      password: ""
      ssl: false
      channel: phoenixholograms
```

Source: https://www.phoenixplugins.com/docs/phoenix-holograms/features/storage