0

我编写了一个用于安排备份过程的脚本。在该脚本中,我想触发一封邮件给相应的用户和管理员用户,因为“备份在 $date $time 为 $username 成功完成。我能做什么。然后我需要哪些包安装...?请帮帮我...!

#!/bin/bash

echo "---welcome to File Backup process---" 

whoami

#echo "--Please enter your public Key name--"
#read username

username=$(whoami)

echo "username:$username"

rsync -avz --delete --exclude=".bash_history" --exclude=".bash_logout" --exclude=".bashrc" --exclude=".cache*" --exclude=".profile" --exclude=".ssh*" /home/$username/ $username@server:/home/$username/

echo "--Backup completed--"
4

1 回答 1

0

. 您可以使用带有附件文件的 mailx 和邮件。

echo 'Content' | mail -aFrom:from@domain.com -s 'Subject' -A attachment to@domain.com

(echo 'Content';uuencode filename file-attachment-path) | mailx -s subject to@domain.com
于 2017-09-02T06:27:12.173 回答