You are not logged in.
I'm sure this is very simple.
I run an rsync to backup my machines as a cron job weekly.
I would quite like to be able to see the output of that in a log file and I would also like to be able to have a log file if I manually invoke the backup.
Also when the backup is done I would like it to send me an email stating that, with the logfile attached.
I'm not sure how to do the first part but I'm sure the email could be achieved through sendmail but I'm not sure how to add an attachment with that.
Any help extremely appreciated.
Last edited by llawwehttam (2010-09-09 23:19:58)
Offline
mailx -s [YourSubject] -a [PathToYourAttachment] you@somewhere.
Offline
Thanks a bunch. Done some more looking into the first part.
Would this work?
bash$ rsync -avzuh user@computertobackup:~/ /mnt/backups > "/mnt/backups/backuplog-`date +"%m-%d-%y`"
Offline
mailx -s [YourSubject] -a [PathToYourAttachment] you@somewhere.
You can also add some extra info in the body of the message
echo "Done" | mailx -s subject -a attachement login@host
Offline
Thanks. I'll see what I can come up with and post the result to make sure it'll work.
Offline
I have mailx installed but typing mailx in a terminal gives: /usr/sbin/sendmail no such file or directory
I have looked at a lot of tutorials for setting up sendmail but most of them compile from source and are used for mail servers.
Any advice?
Offline
set sendmail="/usr/bin/mailx"
Offline
set sendmail="/usr/bin/mailx"
Thanks. I didn't see your old post on this when I searched.
> I am guessing this is a newer version of the same mailx?
It's a bit ore complicated http://heirloom.sourceforge.net/mailx.htmlDo you have sendmail installed?
I had a problem like this too.
http://bbs.archlinux.org/viewtopic.php? … 80#p765580Run
ln -s /usr/bin/mailx /usr/sbin/sendmail
and try again.
Offline
The 'set' command is better than using symlinks ;P
Offline
Thanks. I guess symlinks can create conflicts then.
I'm just really getting into linux. Been using it 6 years and have only scraped the surface. XD
Offline
As /usr/bin/mailx didn't exist I assumed that it is now /usr/bin/mail which exists.
However set sendmail="/usr/bin/mail" had no affect on the output.
Offline
I'm using mailx-heirloom, not mailx - don't know if that makes a difference or not.
I think you need to configure it.
[karol@black ~]$ cat /etc/nail.rc
set sendmail="/usr/bin/mailx"
set smtp=smtp.gmail.com:587
set smtp-use-starttls
set ssl-verify=ignore
set ssl-auth=login
set smtp-auth-user=login@host
set smtp-auth-password=PASSWORD
I'm using it with my gmail account.
As I wrote in the old post you've found, it's a bit complicated (the mailx / mailx-heirloom thing).
Last edited by karol (2010-09-09 22:28:31)
Offline
Installed mailx-heirloom as it seems more people use it.
Set up the config file but on typing the command:
echo "test" | mailx -s "testing" user@host.com
I get:
usr/sbin/sendmail: No such file or directory
"/home/user/dead.letter" 8/218
. . . message not sent.
Any ideas?
Offline
Installed mailx-heirloom as it seems more people use it.
Set up the config file but on typing the command:
echo "test" | mailx -s "testing" user@host.com
I get:
usr/sbin/sendmail: No such file or directory
"/home/user/dead.letter" 8/218
. . . message not sent.Any ideas?
Are you sure it's 'nail.rc'?
I'm using that nail.rc config I posted and I'm fine.
You can try 'ln -s /usr/bin/mailx /usr/sbin/sendmail' if nothing else works.
Last edited by karol (2010-09-09 22:53:38)
Offline
I had got the port wrong but now I have a nice new error:
smtp-server: Ip-ad-dr-ess <myusername@localhost.localdomain>:sender address not owned by user myuser@host.com
I guess I have to get mailx to send it as myusername@host.com instead of @localhost.localdomain but how do I do that?
Offline
I had got the port wrong but now I have a nice new error:
smtp-server: Ip-ad-dr-ess <myusername@localhost.localdomain>:sender address not owned by user myuser@host.com
I guess I have to get mailx to send it as myusername@host.com instead of @localhost.localdomain but how do I do that?
I'm using it to e-mail things to myself - I think you're trying to do exactly that, so it should work.
I've been using it with gmail only, so I don't know if and how it works for other providers.
I don't recall making any additional configurations and I've never been presented with an error like yours.
set smtp-auth-user=MY.LOGIN@gmail.com
set smtp-auth-password=PASSWORD
I have my real login and password there and it just works.
Offline
Interesting. I will try with a gmail address to see if it makes a difference.
Offline
Moved to Newbie Corner - and you might want to reword the post title to focus on your mailx issue: it will attract a little more focused scrutiny that way...
Offline
IT LIVES!!!!!!
The best email I have ever recieved:
Subject : testing
Test
Is that a bit sad?
Anyway I am integrating it into a script now.
Will post it when done.
Thanks for all the help.
Offline
I'm sure this could be much refined but here's what I've got:
(Its to be manually invoked for now but I will set a modified version as a cron when I get some more hard drive space.)
#!/bin/bash
DATE=`date +%m-%d-%y`
echo -n "What directory do you want to back up? : "
read DIRECTORY
rsync -avzuh Targetmachine:~/$DIRECTORY . > /home/username/logs/backup-log-$DIRECTORY-$DATE.txt &&
echo "Backup of $DIRECTORY Complete, Log attached" | mailx -s "Backup Complete" -a "/home/username/logs/backup-log-$DIRECTORY-$DATE.txt" user@HOST
This means I can leave DIRECTORY blank, which would backup the entire home folder, but I don't need to.
I usually keep a track of what I've saved in the week so I can just backup the folders that I feel need it.
Offline
As you're using 'u' option in rsync, you can backup the whole ~ folder and let rsync do the work. If you don';t need something, you can exclude it.
Offline
Thanks. How would I exclude all files beginning with . ?
Offline
Thanks. How would I exclude all files beginning with . ?
rsync -avuzb --exclude '.*'
seems to work.
Offline
Thanks. Will use that.
Offline