Cron job to e-mail database - is it possible

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
eurocms
Forum Members
Forum Members
Posts: 30
Joined: Fri May 22, 2009 1:55 pm

Cron job to e-mail database - is it possible

Post by eurocms »

I got my cron job set to backup the database on a weekly basis (using Webmin).  What I'd like to do is to set a cron job to grab the file and then e-mail it out.  Is it possible?
Thanks much!
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Cron job to e-mail database - is it possible

Post by Wishbone »

If your hosting account is Linux, and you have access to uuencode, you can do the following in your cron entry:

uuencode /path/to/my-backup.sql backup.sql | mail -s "Backup" eurocms@your-domain.com

Your email applicatation will see the encoded information and show it to you as an attachment.

http://www.shelldorado.com/articles/mai ... ments.html
Last edited by Wishbone on Tue Dec 07, 2010 12:51 am, edited 1 time in total.
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Cron job to e-mail database - is it possible

Post by Wishbone »

uuencode output is quite a bit larger than the actual file. To send the actual file as a MIME attachment, you can use 'mutt' if you have that installed

mutt -s "Backup" -a /path/to/my-backup.sql eurocms@your-domain.com < /dev/null
Post Reply

Return to “Tips and Tricks”