fm250
asked on
backup script with email notification
I want to have a backup script that would backup using the rsync and run everyday. when the script is done I would like it to send me a notification email with result. for example if I put
rsync -av /Data/ /backup/
I would like to see the result of that as if I am running it from the shell. Please provide the script if possible. I have latest kernal. Thank you
rsync -av /Data/ /backup/
I would like to see the result of that as if I am running it from the shell. Please provide the script if possible. I have latest kernal. Thank you
ASKER
So
>> rsync -av /Data/ /backup/ | mail myemailaddress@somwehere.c om
will this one wait for all of output of the command
rsync -av /Data/ /backup/
and then send it to email. what if you want more nice email for example
subject: backup
body: result of the backup sync -----
result here
--end---
also what does this one do.
rsync -av /Data /backup/ 2>&1 | mail myemailaddress@somwehere.c om
and finally this should be in a file whatevername.sh and put in the /etc/cron.daily/
correct?
>> rsync -av /Data/ /backup/ | mail myemailaddress@somwehere.c
will this one wait for all of output of the command
rsync -av /Data/ /backup/
and then send it to email. what if you want more nice email for example
subject: backup
body: result of the backup sync -----
result here
--end---
also what does this one do.
rsync -av /Data /backup/ 2>&1 | mail myemailaddress@somwehere.c
and finally this should be in a file whatevername.sh and put in the /etc/cron.daily/
correct?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
will
>> a.tmp
append to the file or replaced it?
>> a.tmp
append to the file or replaced it?
>> appends
> replaces and starts anew.
> replaces and starts anew.
ASKER
What does 2>&1 means? in rsync -av /Data /backup/ 2>&1 >>a.tmp;
also how do I add ther errors?
Thanks!
also how do I add ther errors?
Thanks!
2>&1 means "redirect the stream #2 (stderr) to stream #1(stdout)", i.e. append all error messages to your standard output.
rsync -av /Data /backup/ 2>&1 | mail myemailaddress@somwehere.c
if you want to send the error messages (stderr) too.
See
man mail
for more switches (subject line, etc.)