raziul / laravel-backup-telegram
Send your Laravel backup files to a Telegram chat or channel.
Fund package maintenance!
Raziul Islam
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-backup: ^9.3
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
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
- Create a Telegram Bot:
- Talk to @BotFather on Telegram and create a new bot. Copy the API token.
- 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.
- Get the Chat ID:
- Use @userinfobot or getIDs bot to find your chat or channel 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.