For When Discord Dies - How to Create a Public Mirror of a Discord Server
Discord Public URL Mirror Guide
I will not make this an essay. Discord is a closed platform and there is little way to keep your data unless you own it. Hereâs a guide to make that happen. Please get consent of the members in the server before doing this.
What is the goal of this post?
- Get a download of a discord server (using Tyrrrz/DiscordChatExporter)
- Publish it online (using slatinsky/DiscordChatExporter-frontend - DEMO here)
- NOTE THIS GUIDE IS ONLY FOR SMALLER SERVERS as it redownloads all chats every day and does not use incremental mechanisms (please see https://github.com/slatinsky/DiscordChatExporter-incrementalBackup as a solution)
For my setup I am using the oracle cloud VPS with Cloudflare Zero trust tunnels along with Docker. Please use this guide for setting up Cloudflare Zero Trust Tunnels: Self-Host the Right Way (Docker + Cloudflare Tunnels).
1. Setup Discord Bot / User to obtain Token
It is advised to make a discord bot as it is against discord TOS to use botting activities on a personal user account. However, when you are unable to invite the bots as they require user permissions an alternate account would be the most practical advice to avoid a ban on your personal account even though it rarely occurs.
For setting up a discord bot: Creating a Bot Account The Bot will need the permissions of - View Channels, Read Message History, and Message Content Intent Then go to âBot > Reset Tokenâ to obtain the token
For obtaining a personal user token:
- Open Discord in your web browser (discord.com/app).
- Open developer tools (Control + Shift + I, or F12) and open the Network tab within it.
- Click on the Applications Tab
- Click on the âLocal Storageâ > âhttps://discord.comâ
- Click on a different Discord server so that the webpage soft refreshes
- Search for âtokenâ and grab the token
- DO NOT SHARE YOU DISCORD TOKEN WITH ANYONE OTHER THAN YOURSELF
2. Setting Up Discord Chat Exporter
Please note these instructions will vary depending on how exactly your server is setup and what hardware it is using. But follow these general directions.
a. Download the terminal/cli app:
1
wget https://github.com/Tyrrrz/DiscordChatExporter/releases/latest/download/DiscordChatExporter.Cli.linux-arm64.zip
b. install unzip
1
sudo apt install -y unzip
c. Unzip the folder (note: I have exported the application into a folder named âexportâ in the current directoryâ
1
DiscordChatExporter.Cli.linux-arm64.zip -d export
d. Check to see discord CLI is working
1
export/DiscordChatExporter.Cli --help
e. Download the Discord Server (note: I have downloaded the server into a folder named âserverâ
1
DiscordChatExporter.Cli exportguild --token DISCORD_TOKEN -g SERVER_ID --media --reuse-media --markdown false --format Json --include-threads All --output ./server/
DISCORD_TOKEN = Obtain from previous instructions SERVER_ID = Go to âUser Settings > Advanced > Enable Developer Modeâ then right-click on the server and âCopy IDâ OUTPUT_FOLDER_PATH = I chose to go with ./server/
Setup DiscordChatExporter-frontend docker container
a. Pull the front end image from docker hub:
1
docker pull slada/dcef:main
b. Navigate to the folder with your exports downloaded in the previous step. I used the folder âserverâ
1
cd server
c. Setup a docker-compose.yml file [The networks section is needed for Cloudflare Zero Trust Network]
services:
dcef:
image: slada/dcef:main
container_name: dcef
restart: always
# Equivalent to: -p 127.0.0.1:21011:21011
ports:
- "127.0.0.1:21011:21011"
# Equivalent to: --volume "$(pwd):/dcef/exports" --volume dcef_cache:/dcef/cache
volumes:
- ./:/dcef/exports
- dcef_cache:/dcef/cache
# Equivalent to: -it
tty: true
stdin_open: true
volumes:
dcef_cache:
networks:
default:
external: true
name: proxy-network
d. Setup a .env file by entering your domain. This will also need to be setup in Cloudflare and match the same domain that you put there
1
DOMAIN=cord.domain.com
e. In the same directory start up the docker container
1
docker compose up -d
Setup Cloudflare
Go to Cloudflare > Zero Trust > Tunnels > Connectors > Right-click then Configure > Published application routes > Add Published Application Routes
1
2
Domain = cord.domain.com
Service = http://dcef:21011
Create a script to backup daily
a. Create a new shell file
1
nano update-daily.sh
b. Input the following [Make sure to slot the TOKEN, GUILD ID, and SERVER_PATH location]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
set -euo pipefail
# --- Configuration ---
TOKEN="PASTE_YOUR_TOKEN_HERE"
GUILD_ID="PASTE_ID_HERE"
OUTPUT_DIR="./server"
COMPOSE_DIR="SERVER_PATH/server"
SERVICE_NAME="dcef" # must match the *service name* in docker-compose.yml
# --- Run exporter ---
export/DiscordChatExporter.Cli exportguild \
--token "$TOKEN" \
-g "$GUILD_ID" \
--media \
--reuse-media \
--markdown false \
--format Json \
--include-threads All \
--output "$OUTPUT_DIR"
# --- Restart container/service after export ---
pushd "$COMPOSE_DIR" >/dev/null
docker compose down -v
docker compose up -d "$SERVICE_NAME"
popd >/dev/null
c. Make the script executible
chmod +x update-daily.sh
d. Run it once to download the server initially
1
./update-daily.sh
e. Install and activate cron
1
2
3
sudo apt install cron
sudo systemctl enable --now cron
systemctl status cron
f. Add the script to Cron - This one starts the script at 2AM every day
1
crontab -e
1
0 2 * * * /full/path/to/update-daily.sh >> /full/path/to/update-daily.log 2>&1
Thatâs it. Enjoy.
Photo by Mariia Shalabaieva on Unsplash