Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 19, 2025

This PR implements comprehensive Django Signals support for django-dbbackup, allowing users to hook into backup and restore operations to perform custom actions.

New Signals

Database Operations

  • dbbackup.signals.pre_backup - Sent before a database backup starts
  • dbbackup.signals.post_backup - Sent after a database backup completes
  • dbbackup.signals.pre_restore - Sent before a database restore starts
  • dbbackup.signals.post_restore - Sent after a database restore completes

Media Operations

  • dbbackup.signals.pre_media_backup - Sent before a media backup starts
  • dbbackup.signals.post_media_backup - Sent after a media backup completes
  • dbbackup.signals.pre_media_restore - Sent before a media restore starts
  • dbbackup.signals.post_media_restore - Sent after a media restore completes

Usage Example

from django.dispatch import receiver
from dbbackup import signals

@receiver(signals.pre_backup)
def backup_started(sender, database, **kwargs):
    print(f"Starting backup of database: {database['NAME']}")

@receiver(signals.post_backup)  
def backup_completed(sender, database, filename, **kwargs):
    print(f"Completed backup of {database['NAME']} to {filename}")

Signal Arguments

Each signal provides relevant context:

  • Database signals: database config, connector, servername, filename, storage
  • Media signals: servername, filename, storage

Common use cases include:

  • Sending notifications when backups complete
  • Logging backup/restore operations
  • Integration with monitoring systems
  • Custom validation before restores
  • Triggering webhooks to external services

Implementation Details

  • All signals are defined in dbbackup.signals module
  • Signals are sent at appropriate points in backup/restore command methods
  • Full backward compatibility maintained
  • Comprehensive test coverage (9 new tests)
  • Detailed documentation with examples

The implementation uses minimal, surgical changes to existing command classes while providing powerful extensibility for users who need to customize backup/restore workflows.

Fixes #613.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Archmonger/django-dbbackup/discussions/578
    • Triggering command: curl -s REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 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.

@Archmonger Archmonger requested a review from Copilot August 19, 2025 04:04
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Django Signals support for the django-dbbackup package, allowing users to hook into backup and restore operations for both database and media files. The implementation adds 8 new signals that are sent before and after each operation type.

  • Adds comprehensive Django signals for all backup and restore operations
  • Provides consistent signal arguments with relevant context data
  • Maintains full backward compatibility with existing functionality

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dbbackup/signals.py Defines all 8 new Django signals for backup/restore operations
dbbackup/management/commands/dbbackup.py Integrates pre_backup and post_backup signals
dbbackup/management/commands/dbrestore.py Integrates pre_restore and post_restore signals
dbbackup/management/commands/mediabackup.py Integrates pre_media_backup and post_media_backup signals
dbbackup/management/commands/mediarestore.py Integrates pre_media_restore and post_media_restore signals
tests/test_signals.py Comprehensive test suite covering all signal functionality
docs/src/signals.md Complete documentation with usage examples and API reference
docs/mkdocs.yml Adds signals documentation to navigation
CHANGELOG.md Documents the new signals feature

@Copilot Copilot AI changed the title [WIP] Add support for Django Signals Add Django Signals support for backup and restore operations Aug 19, 2025
@Copilot Copilot AI requested a review from Archmonger August 19, 2025 04:07
Copilot finished work on behalf of Archmonger August 19, 2025 04:07
@Archmonger Archmonger marked this pull request as ready for review August 19, 2025 05:23
@Archmonger Archmonger merged commit 6869166 into master Aug 19, 2025
19 checks passed
@Archmonger Archmonger deleted the copilot/fix-613 branch August 19, 2025 05:36
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.

Add support for Django Signals

2 participants