WebFaction
Community site: login faq

How to extend the DB backup cron command found in the docs, with sending the sql file to an email address? Or even zip it before sending.. (http://docs.webfaction.com/user-guide/databases.html#databases)

Thanks

asked 05 Jan '12, 10:16

sub
124
accept rate: 0%


Hi,

You can send it using sendmail by following the second method here or by using mutt.

permanent link

answered 05 Jan '12, 23:07

neeravk
1.5k3412
accept rate: 41%

Thank you neeravk, I found on net of course I can send with sendmail and even mutt, but how? How to pass the generated file name to mutt in one crontab line? If it's possible..

permanent link

answered 06 Jan '12, 00:40

sub
124
accept rate: 0%

You can write commands in cron separated by ; in a single line or you can just write all the commands in a .sh file, make it executablable using "chmod +x script.sh" and run that in a single line in crontab.

(06 Jan '12, 00:49) neeravk

thank you, trying the first one first

(06 Jan '12, 00:55) sub

bad minute error.. trying with .sh

(06 Jan '12, 01:07) sub

I can zip and send by email but after unpacking zip I get a 0 byte file.

EMAIL="info@email.com" MYSQL_PWD=xxxxxxxxxxxxx /usr/bin/mysqldump -u subdesign subdesign > $HOME/db_backups/subdesign-date +\%Y\%m\%d.sql | gzip > $HOME/db_backups/backup.sql.gz 2>> $HOME/db_backups/cron.log echo 'backup' | mutt -a $HOME/db_backups/backup.sql.gz $EMAIL -s "This is a backup" rm $HOME/db_backups/backup.sql.gz

(06 Jan '12, 03:21) sub

These commands don't appear to be semicolon-delimited, so only the first is being executed.

Also, the command itself looks incorrect. You are using mysqldump to save the backup to $HOME/db_backups/subdesign-$(date +\%Y\%m\%d).sql; what is being fed into gzip?

(06 Jan '12, 03:28) ryans ♦♦

yes first I tried with semicolons with the same result. Now I can send the sql file unpacked well, so the zip packaging has issue some way

EDIT: yes your second suggestion seems to be true, checking..

(06 Jan '12, 03:42) sub

piping gzip after mysqldump, zip generated correctly, thank you!

(06 Jan '12, 04:17) sub
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×261
×81
×36
×7
×4

question asked: 05 Jan '12, 10:16

question was seen: 4,768 times

last updated: 06 Jan '12, 04:17

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM