LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command line sending of mail attachments ( DB backups) (https://www.linuxquestions.org/questions/linux-newbie-8/command-line-sending-of-mail-attachments-db-backups-850839/)

gamorgan 12-17-2010 06:02 AM

Command line sending of mail attachments ( DB backups)
 
Hello all

I'm am not remotely familiar with the linux operating sytem and just need a simple 'cut and paste solution' that will allow me to send .gz files as mail attachments, from the command line.

Recently I moved my website to new hosting company, they are using cpanel and I have set up a couple of commands; the cpanel scheduler runs them for me as required.

1. creates an mysql dump and saves it to folder ( in root of my space ). Works fine.

2. delete the file created above, after 15 mins. Also works fine

What I really want to do is email the .gz to myself before it is deleted, this is were I am stuck.
This is possible ( I believe ) but it is beyond my understanding and ability to write the script/command that will make this happen.

Please make any instructions really simple and clear as I am really new to this.

Any help would be very much appreciated.

There are several Pearl and PHP modules installed on the server and this information is provided below and may be helpful to you (but I certainly to not know anything about this type of stuff).


More info about the server to come.

gamorgan 12-17-2010 06:14 AM

modules on the server that I thought were relevant. There are a great many more.


Mail::Address
Mail::Cap
Mail::Field
Mail::Field::AddrList
Mail::Field:: Date
Mail::Field::Generic
Mail::Filter
Mail::Header
Mail::Internet
Mail::Mailer
Mail::Mailer::qmail
Mail::Mailer::rfc822
Mail::Mailer::sendmail
Mail::Mailer::smtp
Mail::Mailer::testfile
Mail::Send

There are also a great number of mime modules installed, please ask me about anything specific that might be needed.

kontrabant 12-17-2010 07:36 AM

You could use:
1. for one file:

uuencode /path/to/mysql_dump.gz | mail -s "Mysql dump" user@somedomain.net


2. multiple files

mutt -s "Mysql dump" -a /path/to/mysql_dump.gz /path/to/mysql_dump1.gz -- user@somedomain.net < /dev/null

gamorgan 12-17-2010 10:09 AM

Thanks for the reply, I will try them and send a reply shortly.

GM

gamorgan 12-17-2010 11:40 AM

Hi and thanks for your efforts

The first command did indeed send a message but no file can be attached.

mutt does not appear to be running, as the second command has no effect and I have tried many configurations of this, from the web.


Mmmmmmmmmmm anyone else have a solution?

speck 12-18-2010 01:56 AM

Try the following

Code:

mailx -a attachment.gz -s "Subject Here" user@domain.com </dev/null

gamorgan 12-19-2010 02:49 AM

Thanks for your reply


No luck with this one, not the slightest hint of anything going on.

GM

colucix 12-19-2010 03:16 AM

Code:

uuenview -m email -f "my_email" -s "test subject" -a attachment.tar.gz << EOF
Greetings,
Alex
EOF

This will send a mail to email, putting the my_email address in the From: field and test subject in the Subject. The file specified with option -a will be attached to the mail. The here document serves the mail body. See man uuenview for more options. The uuenview command is provided by the uudeview package. Hope this helps.


All times are GMT -5. The time now is 03:56 PM.