A simple Discord bot that backs up text channel messages and attachments from a server into local files.
The bot creates a timestamped backup folder, saves each text channel’s messages into a messages.txt file, and downloads attachments into a dedicated attachments folder.
- Usable as a Docker container
- Backs up all text channels in a Discord server
- Saves messages in chronological order
- Downloads message attachments
- Organizes backups by timestamp and channel
- Logs errors to a traceback file
- Sends a backup-start notification to a configured announcement channel
- Automatically shuts down after the backup finishes
Each run creates a new folder inside backups/ using the current date and time.
backups/
└── 2026-05-23_14-30-10/
├── 123456789012345678_general/
│ ├── messages.txt
│ └── attachments/
│ └── 987654321098765432_image.png
└── 234567890123456789_announcements/
├── messages.txt
└── attachments/Each messages.txt file follows this format:
[time] author_name (author_id): message
[2026-05-23 14:25:01] ExampleUser (123456789): Hello world!
[attachment saved] backups/...Never commit your bot token or share it publicly.
Run the bot directly with Python:
python main.pyI personally run it with Docker like this:
docker build -t chat-exporter .
docker run -v "$(pwd)/backups:/backups" chat-exporterThe Docker command mounts your local backups/ folder into the container so backups are saved outside the container and remain available after it exits.
- Sanitization for Windows-based systems.
This project is provided as-is. You may modify and use it for your own Discord servers.