raziul/laravel-backup-telegram

Send your Laravel backup files to a Telegram chat or channel.

v1.0 2025-05-29 17:35 UTC

This package is auto-updated.

Last update: 2025-05-30 06:05:54 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Easily send your Laravel application's backup files directly to a Telegram chat or channel after each successful backup. This package integrates with spatie/laravel-backup to automate backup delivery and supports large file splitting for Telegram's file size limits.

Features

  • Automatically sends backup files to Telegram after each successful backup.
  • Supports sending to both private chats and channels.
  • Handles large backup files by splitting them into Telegram-compatible chunks.
  • Simple configuration and seamless integration with Laravel's backup events.

Requirements

  • PHP 8.2+
  • Laravel 10, 11, or 12
  • spatie/laravel-backup v9.3+
  • A Telegram bot and a chat/channel to receive backups

Installation

Install via Composer:

composer require raziul/laravel-backup-telegram

Publish the config file (recommended):

php artisan vendor:publish --tag="backup-telegram-config"

Telegram Setup

  1. Create a Telegram Bot:
    • Talk to @BotFather on Telegram and create a new bot. Copy the API token.
  2. Add Bot to Your Chat or Channel:
    • For a private chat, start a conversation with your bot.
    • For a channel, add your bot as an administrator.
  3. Get the Chat ID:

Configuration

Update your .env file or the published config/backup-telegram.php:

BACKUP_TELEGRAM_TOKEN=your_bot_token
BACKUP_TELEGRAM_CHAT_ID=your_chat_id
BACKUP_TELEGRAM_CHUNK_SIZE=49 # (optional, in MB, default: 49, max: 49)

Or in config/backup-telegram.php:

return [
    'token' => env('BACKUP_TELEGRAM_TOKEN'),
    'chat_id' => env('BACKUP_TELEGRAM_CHAT_ID'),
    'chunk_size' => env('BACKUP_TELEGRAM_CHUNK_SIZE', 49), // MB
];

How it Works

  • On every successful backup (spatie/laravel-backup event), the package will automatically send the backup file to your configured Telegram chat/channel.
  • If the file is larger than the Telegram limit (default 49MB), it will be split and sent in parts.

Usage

No manual usage is required! Once installed and configured, the package listens for backup events and sends the files automatically.

If you want to trigger a backup manually:

php artisan backup:run

Advanced: Handling Large Files

  • By default, files larger than 49MB are split into chunks and sent as multiple messages.
  • You can adjust the chunk size in your config, but it cannot exceed 49MB due to Telegram's limitations.

Testing

Run the test suite:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Contributions are welcome! Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.