Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoBackup Bot

Techlyn Developments Project Discord.js v14 MySQL Backups SQLite State

A modern discord.js v14 MySQL backup bot with slash commands, prefix commands, SQLite-backed state, and scheduled archive generation built for clean public deployment.

Overview

AutoBackup Bot is a production-style Discord utility for managing MySQL backup targets from inside a Discord server. It is designed as a clean public repo with environment-based configuration, modern command structure, and a lightweight SQLite layer for local bot state.

This version is organized like a polished Techlyn Developments project: simple to clone, easy to configure, and ready to publish as a portfolio-quality GitHub repository.

Tech Stack

Tech stack icons

Highlights

  • Dual command support with slash commands and prefix commands
  • Modern src/ structure for commands, events, services, config, and database logic
  • SQLite database for bot settings, registered backup targets, and backup logs
  • MySQL dump generation using mysqldump
  • Gzip-compressed backup archives for cleaner storage
  • Scheduled automatic backups with configurable interval
  • Manual backup controls for single targets or all targets
  • Public-repo ready environment configuration with no hardcoded secrets

Project Structure

.
|-- src
|   |-- commands
|   |-- config
|   |-- database
|   |-- events
|   |-- services
|   |-- utils
|   |-- index.js
|   `-- register-commands.js
|-- .env.example
|-- .gitignore
|-- package.json
|-- index.js
`-- register.js

Commands

Slash Prefix Description
/add !add Add or update a MySQL backup target
/remove !remove Remove a backup target
/list !list Show all registered targets
/backup !backup Run a manual backup for one target or all targets
/settings !settings Manage interval, notifications, and auto-backup state
/panel !panel Open the quick-action backup control panel
/help !help Show command usage

Requirements

  • Node.js 18.17+ recommended
  • npm 9+
  • A Discord bot application
  • Access to one or more MySQL databases

Full Setup

1. Install dependencies

npm install

2. Configure environment variables

The repo includes .env.example.

Create a local .env file with values like this:

DISCORD_TOKEN=your_bot_token
CLIENT_ID=your_discord_application_client_id
GUILD_ID=your_test_server_id
PREFIX=!
OWNER_IDS=123456789012345678,987654321098765432
BACKUP_DIR=backups
SQLITE_PATH=data/autobackup.sqlite
AUTO_BACKUP_INTERVAL_MINUTES=60
BACKUP_NOTIFY_CHANNEL_ID=123456789012345678
BACKUP_TIMEZONE=Asia/Calcutta

3. Create the Discord bot

  1. Open the Discord Developer Portal.
  2. Create a new application.
  3. Open the Bot tab and create a bot user.
  4. Copy the bot token into DISCORD_TOKEN.
  5. Copy the application ID into CLIENT_ID.
  6. If you want fast slash-command updates while testing, put your server ID in GUILD_ID.

4. Enable required bot intents

In the Discord Developer Portal, enable:

  • Server Members Intent only if you later expand member-based features
  • Message Content Intent because prefix commands use message content

5. Invite the bot to your server

Use an OAuth2 URL with:

  • bot
  • applications.commands

Recommended bot permissions:

  • View Channels
  • Send Messages
  • Embed Links
  • Attach Files
  • Read Message History
  • Use Slash Commands
  • Manage Guild for admins who should control backups

6. Register slash commands

npm run register

If GUILD_ID is set, commands are registered instantly to that server.
If GUILD_ID is empty, commands are registered globally and can take longer to appear.

7. Start the bot

npm start

For development with reloads:

npm run dev

How To Use

Add a backup target

/add name:main-db connection:mysql://user:password@127.0.0.1:3306/database_name

Or with the prefix command:

!add main-db mysql://user:password@127.0.0.1:3306/database_name

Run a manual backup

/backup name:main-db

Or:

!backup main-db

To back up everything:

!backup all

Change automatic backup interval

/settings interval minutes:120

Or:

!settings interval 120

Enable automatic backups

/settings enable

Or:

!settings enable

What Gets Stored

SQLite stores:

  • Bot settings
  • Registered MySQL targets
  • Backup log history
  • Last backup timestamps

Generated backup files are written to the directory defined by BACKUP_DIR.

Notes For Public Release

  • Rotate any old tokens or credentials before publishing the repository
  • Keep .env, backup archives, and SQLite files out of git
  • This public build does not expose raw SQL execution commands
  • If you are publishing this as a Techlyn Developments project, you can safely use this README as the base presentation

Scripts

npm start
npm run dev
npm run register

License

This project is currently marked with the ISC license in package.json.

About

No description, website, or topics provided.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages