Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 21, 2025

Overview

This PR adds the ability to exclude specific tables and/or databases from MySQL backups when using the yolo-backup script. This is useful for skipping temporary data, cache tables, or test databases that don't need to be backed up.

Changes

New Environment Variables

  • MYSQL_IGNORE_TABLES: Space-separated list of tables to exclude from backups (format: database.table)
  • MYSQL_IGNORE_DATABASES: Space-separated list of databases to exclude from backups

Implementation Details

xtrabackup Support

The xtrabackup backup function now builds exclude options dynamically:

  • Uses --databases-exclude=<database> for each excluded database
  • Uses --tables-exclude=<db.table> for each excluded table
  • Logs each exclusion for audit trail

mysqldump Support

The mysqldump backup function implements intelligent database filtering:

  • Uses --ignore-table=<db.table> for excluding specific tables
  • When databases are excluded, dynamically queries all databases and filters out:
    • User-specified databases (via MYSQL_IGNORE_DATABASES)
    • System databases (information_schema, performance_schema, sys)
  • Uses --databases <filtered_list> when exclusions are present
  • Falls back to --all-databases when no database exclusions are specified

Usage Examples

Exclude specific tables:

MYSQL_IGNORE_TABLES="mydb.cache mydb.sessions" yolo-backup

Exclude entire databases:

MYSQL_IGNORE_DATABASES="test_db temp_db" yolo-backup

Exclude both tables and databases:

MYSQL_IGNORE_DATABASES="test_db temp_db" \
MYSQL_IGNORE_TABLES="prod.cache prod.sessions prod.logs" \
yolo-backup

Backward Compatibility

All changes are fully backward compatible:

  • If environment variables are not set, the script behaves exactly as before (backs up all databases)
  • Existing backups and restore procedures remain unaffected
  • No changes to the script's interface or other functionality

Testing

  • ✅ Shell syntax validation (bash -n)
  • ✅ Shellcheck linting via pre-commit hooks
  • ✅ Manual verification of exclude logic for both xtrabackup and mysqldump
  • ✅ Database filtering logic tested with simulated database lists
  • ✅ Help output verified to include new variables and examples

References

Closes #<issue_number>

Original prompt

This section details on the original issue you should resolve

<issue_title>feat(yolo-backup): add the ability to ignore tables and/or databases from mysql backups</issue_title>
<issue_description># Context

When backuping MySQL, we need the ability to ignore certaines tables and/or databases.

Goal

Comments on the Issue (you are @copilot in this section)

Fixes #113


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 21, 2025 10:05
…backups

Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Co-authored-by: bdossantos <245284+bdossantos@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ability to ignore tables and databases in MySQL backups feat(yolo-backup): add ability to ignore tables and databases from MySQL backups Oct 21, 2025
Copilot AI requested a review from bdossantos October 21, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(yolo-backup): add the ability to ignore tables and/or databases from mysql backups

2 participants