我编写了一个用于调度备份过程的脚本。在该脚本中,我想将邮件触发给相应的用户和管理用户为" backup at able $ username在$ date $ $ time成功完成的备份。我该怎么办。然后我需要安装哪些包...?请帮助我...
#!/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--"
。您可以使用MailX和邮件和artachmet文件。
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