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.
- 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.
- PHP 8.2+
- Laravel 10, 11, or 12
- spatie/laravel-backup v9.3+
- A Telegram bot and a chat/channel to receive backups
Install via Composer:
composer require raziul/laravel-backup-telegram
Publish the config file (recommended):
php artisan vendor:publish --tag="backup-telegram-config"
- 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.
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
];
- 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.
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
- 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.
Run the test suite:
composer test
Please see CHANGELOG for more information on what has changed recently.
Contributions are welcome! Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.