# 设置变量
source_folder="/vw-data" # 备份路径
backup_folder="/root"
telegram_token=""# tg机器人token
telegram_chat_id=""# 自己的tg id
export TZ="Asia/Shanghai"
# 创建备份目录
mkdir -p "$backup_folder"
# 压缩文件夹并命名
backup_filename="backup_$(date +"%Y%m%d_%H%M%S").tar.gz"
tar -czvf "$backup_folder/$backup_filename" $source_folder
# 发送到Telegram
curl -s -F document=@"$backup_folder/$backup_filename" "https://api.telegram.org/bot$telegram_token/sendDocument?chat_id=$telegram_chat_id"
# 删除本地压缩包(可选)
rm "$backup_folder/$backup_filename"
来源:https://hostloc.com/forum.php?mod=redirect&goto=findpost&ptid=1258848&pid=15094567