> ## Documentation Index
> Fetch the complete documentation index at: https://docs.discord-bot.xxczaki.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating to Self-Hosted

> Export your data from the hosted service and import it into your own instance

If you're moving from the hosted service to a self-hosted deployment, you can export your bot's data and import it into your own Redis instance. This preserves your playback statistics, query cache, and queue recovery state.

## What's included in the export

The export contains all Redis keys stored by your bot instance as a JSON file:

| Data                    | Redis key pattern              | Description                                 |
| ----------------------- | ------------------------------ | ------------------------------------------- |
| Query cache             | `discord-player:query-cache:*` | Cached search results (24h TTL)             |
| Playback statistics     | `discord-player:stats:*`       | Track and playlist play history             |
| Queue recovery          | `queue-recovery:*`             | Last saved queue state for automatic resume |
| External playlist cache | `external-playlist-cache:*`    | Cached Spotify playlist metadata            |

<Note>
  Playlist definitions are stored as Discord messages in your `PLAYLISTS_CHANNEL_ID` channel, not in Redis. As long as your self-hosted bot has access to the same channel, playlists will work without any migration.
</Note>

### What's not included

The **Opus audio cache** (pre-encoded audio files for instant replay) is stored on disk, not in Redis, so it is not part of the export. Your self-hosted instance will rebuild this cache automatically as you play tracks.

## Step 1: Export your data

In the [dashboard](https://app.discord-bot.xxczaki.com), click **Export Data** on your bot instance card. This downloads a JSON file containing all your Redis data.

## Step 2: Set up your self-hosted instance

Follow the [Self-Hosted](/hosting/self-hosted) guide to deploy your own bot. Make sure your Redis instance is running before proceeding.

## Step 3: Import the data

Use the provided import script to load the exported data into your Redis instance. The script reads the JSON export and restores each key.

The export file is a flat JSON object where each key is a Redis key and each value is the stored string. You can pipe it into `redis-cli` using [`jq`](https://jqlang.org):

```bash theme={null}
cat export.json | jq -r 'to_entries[] | "SET \(.key) \(.value | @json)"' | redis-cli -u redis://localhost:6379
```

Replace `redis://localhost:6379` with your Redis connection string. Both `jq` and `redis-cli` (part of the `redis-tools` / `redis` package) need to be installed on your machine.

## Step 4: Start your bot

Start your self-hosted bot. It will pick up the imported data automatically – cached queries will resolve instantly and your playback statistics will be preserved.
