Complete automatic backup system for servers using USB devices, with digital signature authentication, Telegram notifications, and backup file encryption.
- โ Automatic backup when a USB device is connected
- โ Digital signature authentication with RSA-2048
- โ Real-time notifications via Telegram
- โ Backup encryption with AES-256-CBC
- โ Automatic compression with gzip
- โ systemd service for continuous execution
- โ Detailed audit logs
Auto_Backup_Linux/
โโโ README.md # Documentation
โโโ install.sh # Automatic installer
โโโ main.sh # Main system script
โโโ gen_keys.sh # RSA key generator
โโโ setup_telegram.sh # Telegram configurator
โโโ backup-system.service # systemd service
โโโ backup_config.conf # USB configuration
โโโ messages.sh # System messaging script
git clone <repository>
cd Auto_Backup_Linux
chmod +x ./install.shsudo ./install.sh --installsudo backup-telegram --setupsudo backup-genkeys "admin_name" ./keys/sudo backup-system --add-key ./keys/"admin_name"_public.pemsudo backup-system --set-passwordsudo systemctl enable backup-system.servicesudo systemctl start backup-system.service- Contact @BotFather on Telegram
- Use the
/newbotcommand - Follow the instructions and obtain the token
- Send a message to the bot
- Visit:
https://api.telegram.org/bot<TOKEN>/getUpdates - Look for
"chat":{"id":XXXXXXXXX}
USB/
โโโ backup_config.conf # Backup configuration
โโโ <sysadmin_id>_private.pem # Sysadmin private key
โโโ sysadmin_id.txt # Sysadmin ID
The corresponding public key must be authorized on the server with
sudo backup-system --add-key <sysadmin_id>_public.pem.
BACKUP_DIRS="/etc /home"
BACKUP_NAME="primary_server"
EXCLUDE_PATTERNS="*.tmp *.log.*"
SYSADMIN_NAME="Administrator"
BACKUP_DESCRIPTION="Backup of critical directories"# View system status
sudo backup-system --status
# Monitor execution in real time
sudo backup-system --monitor
# Add an authorized public key
sudo backup-system --add-key /path/public.pem- Connect a USB device containing the required files
- The system automatically detects the device
- It verifies authentication using the digital signature
- It requests the password via Telegram
- It validates the server password
- It creates encrypted and compressed backups
- It notifies you of completion via Telegram
sudo backup-system --status
systemctl status backup-system.service/etc/backup-system/server.conf- Server configuration/etc/backup-system/authorized_keys- Authorized public keys/etc/backup-system/server_hash- Server password hash/etc/backup-system/telegram.conf- Telegram configuration
/tmp/backup-system/- Temporary files
- Digital signature: Verification using RSA-2048 keys
- Server password: Stored SHA-256 hash
- Key authorization: List of authorized public keys
- Backups: AES-256-CBC with the server password
- Communication: HTTPS for the Telegram API
New backups use the .tar.gz.enc extension: they are compressed with gzip and
then encrypted with OpenSSL. To restore one:
openssl enc -d -aes-256-cbc -pbkdf2 -iter 100000 \
-in primary_server_etc_YYYYMMDD_HHMMSS.tar.gz.enc \
-out backup.tar.gz
tar -xzf backup.tar.gz -C /restore/pathBackups created by earlier versions must be decrypted with the historical
format (without -pbkdf2) before extraction.
journalctl -u backup-system.service -fudevadm monitor --kernel --subsystem-match=blocksudo backup-telegram --test- OS: Debian/Ubuntu Linux
- Privileges: root
- Dependencies: openssl, curl, jq, tar, gzip, udev, systemd, util-linux, coreutils
BACKUP_MAX_SIZE limits each backup size (for example, 1G, 500M, or
1024K). The system checks free USB space and removes any partial file that
exceeds the limit. Only one backup may run at a time; concurrent USB events are
ignored and logged. LOG_RETENTION_DAYS controls cleanup of rotated log files,
not valid backups.
- Network: Internet access for Telegram
Emmanuel Alexis Esperilla Castro
This project is licensed under the MIT License. Feel free to use it for learning and personal projects.
Date: October 6, 2026