• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

send email after mysql backup through bash script in simple way

June 30, 2013 by Sharad Chhetri Leave a Comment

send email after mysql backup through bash script in simple way

In Facebook group one of the user asked this question “how to send email after mysql backup through bash script”.
If you know bash scripting a bit it is just a one liner.
It can be write in more advanced form but here I am using just simple method which is applicable and tested in Red Hat,CentOS, Debian and Ubuntu.

You can use this script in crontab also and schedule it as per your requirement.

Step 1: Create a bash script with file name called db-backup.sh

Note: replace the value like mysql-username,password,database-name, as per your server information.
Change emailid@example.com with your email id.

db-backup.sh

#!/bin/bash

mysqldump -u mysql-username -p password database-name > serverDB.`date +%F_%T`.sql && echo "the mysqldump has been completed- status received at `date +%F_%T`|mail -s mysqldump-status emailid@example.com

Step 2: give it read,write and execute permission only to owner.

chmod 700 db-backup.sh

Step 3: Now you can execute the script directly or can be used in crontab

sh db-backup.sh

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. MySQL backup bash script
  2. Send nagios report as pdf file via email
  3. How to use email id of Gmail for sending nagios email alerts
  4. postgres database backup script using database user password inside
  5. Cassandra backup script on linux system
  6. create noreply email id in postfixadmin mysql database
  7. How to forcefully send mail from mailq in sendmail MTA
  8. Find mysql commands history without mysql server login
  9. How To Use case in Bash Script, Example
  10. Replace keyword with its filename without extension : bash script

Filed Under: Linux, mysql, Tips And Tricks Tagged With: bash script, mysql

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Linux Commands

How to make rm -fr command to be interactive

sed command to display text between two strings or keywords

Useful tail command with examples in Linux/Unix

Linux command to find modified and access date of file/dir/filesystem

yum : how to find rpm package which has certain command or file

group ownership reference to file/dir from other file/dir in linux

grep command to remove blank lines from file

Explore 70+ Articles On Linux Commands

Always Useful Tips And Tricks

Protect from w00tw00t.at.blackhats.romanian.anti-sec

How to protect from port scanning and smurf attack in Linux Server by iptables

postgres database backup script using database user password inside

How to create a file with cat command

Yum Error database disk image is malformed

How to zip the directory in linux with command line

How to convert float to integer number

Explore 90+ Article On "Linux Tips And Tricks"

You Might Like These Articles!

Internal External Command

What is Linux/Unix Internal And External Command

Linux basic command

Linux Basic Commands For Every Beginner

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission but Schools and Colleges can do in their Private Network
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy