I have a simple script to send a back-up of my db to email:
#!/bin/sh
timestamp=$(date '+%d-%m-%Y@%H:%M')
mysqldump -u root -pPASSWORD DBNAME | gzip > /tmp/database_$timestamp.sql.gz
mutt -s "backup from DBNAME | $timestamp" my.g.mail@gmail.com -a /tmp/database_$timestamp.sql.gz < /opt/message.txt
rm /tmp/database_$timestamp.sql.gz
saved in /opt/db_backup.sh
when I run
. /opt/db_backup.sh
I SUCCESSFULLY got email on my gmail!!!
/var/log/mail.log :
- Jan 24 00:30:34 ip-173-32-37-92 postfix/pickup[1483]: 85308320E: uid=1000 from=
- Jan 24 00:30:34 ip-173-32-37-92 postfix/cleanup[1884]: 85308320E: message-id=<20180124003034.GA1873@vista9.ru>
- Jan 24 00:30:34 ip-173-32-37-92 postfix/qmgr[1484]: 85308320E: from=, size=323952, nrcpt=1 (queue active)
- Jan 24 00:30:34 ip-173-32-37-92 postfix/smtp[1887]: connect to gmail-smtp-in.l.google.com[2a00:1450:400c:c04::1a]:25: Network is
unreachable- Jan 24 00:30:35 ip-173-32-37-92 postfix/smtp[1887]: 85308320E: to=<my.g.mail@gmail.com>,
relay=gmail-smtp-in.l.google.com[209.85.203.27]:25, $- Jan 24 00:30:35 ip-173-32-37-92 postfix/qmgr[1484]: 85308320E: removed
I've created a cron task: crontab -e
*/1 * * * * /opt/db_backup.sh
so after a minute CRON worked:
- Jan 24 00:57:01 ip-173-32-37-92 CRON[2034]: (ubuntu) CMD (/opt/db_backup.sh)
and ... I GOT NO EMAIL :(...
/var/log/mail.log :
- Jan 24 01:02:02 ip-173-32-37-92 postfix/pickup[1483]: 01DC83238: uid=1000 from=
- Jan 24 01:02:02 ip-173-32-37-92 postfix/cleanup[2038]: 01DC83238: message-id=20180124010202.01DC83238@ip-173-32-37-92.eu-central-1.compute.internal
- Jan 24 01:02:02 ip-173-32-37-92 postfix/qmgr[1484]: 01DC83238: from=<ubuntu@vista9.ru>, size=674, nrcpt=1 (queue active)
- Jan 24 01:02:32 ip-173-32-37-92 postfix/smtp[2040]: connect to vista9.ru[81.177.141.15]:25: Connection timed out
- Jan 24 01:02:32 ip-173-32-37-92 postfix/smtp[2040]: 01DC83238: to=<ubuntu@vista9.ru>, orig_to=, relay=none, delay=30, delays=0.01/0/30/0, dsn=4.4.1, status=deferred (connect to vista9.ru[81.177.141.15]:25: Connection timed out)
my /etc/mailname:
vista9.ru
What am I doing wrong?
thank you!
/opt/db_backup.sh
actually executable? (note:. /opt/db_backup.sh
would have sourced rather than run it) – steeldriver Jan 24 '18 at 01:45ls -l /opt/db_backup.sh
– steeldriver Jan 24 '18 at 01:53sudo chmod +x /opt/db_backup.sh
– steeldriver Jan 24 '18 at 01:58./
vs. /
– WinEunuuchs2Unix Jan 24 '18 at 03:47