Install required packages:
# Ubuntu/Debian
sudo apt update
sudo apt install sshfs rsync rcloneGenerate a new SSH key pair for rsync.net:
ssh-keygen -t ed25519 -C "club-backup" -f ~/.ssh/rsync_net_keyWhen prompted for a passphrase, press Enter (no passphrase) to allow automated script usage:
- The private key will be saved as
~/.ssh/rsync_net_key - The public key will be saved as
~/.ssh/rsync_net_key.pub
Use ssh-copy-id to copy your public key to the server:
scp ~/.ssh/rsync_net_key.pub 123@tv-s009.rsync.net:.ssh/authorized_keysEnter your password when prompted. This will automatically add your public key to the server's authorized_keys file.
Copy .env.example to .env and configure these variables:
RSYNC_DST= # For sql-backup script
SFTP_DST= # For sql-backup script
RSYNC_NET_SERVER= # Username@server for mounting (e.g. 123@tv-s009.rsync.net)
S3_BUCKET= # Your S3 bucket name
RSYNC_NET_S3_MOUNTDIR= # Local mount point (e.g. /mnt/rsync-s3)
RSYNC_NET_S3_SUBDIR= # Remote directory on rsync.net (e.g. s3-backups)
TELEGRAM_BOT_TOKEN= # Telegram bot token for notifications
TELEGRAM_CHAT_ID= # Telegram chat ID for notifications
TELEGRAM_MENTIONS= # Optional: @username mentions for alerts (e.g. "@admin @user")For S3 backup, configure rclone:
rclone configCreate a remote named 's3' with your S3 credentials.
To receive backup notifications via Telegram:
-
Create a Telegram bot:
- Message @BotFather on Telegram
- Send
/newbotand follow instructions - Copy the bot token
-
Get your chat ID:
- Start a chat with your bot
- Send a message to the bot
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - Find your chat ID in the response
-
Add the values to your
.envfile:TELEGRAM_BOT_TOKEN=your_bot_token_here TELEGRAM_CHAT_ID=your_chat_id_here
Test Telegram notifications:
./send-telegram "Test message"Run S3 backup with notifications:
./s3-backup