MySQL DB Backup Script


#!/bin/bash
# Database credentials
user="username"
password="password"
host="localhost"
db_name="dbname"
# Other options
backup_path="/DB/DB_Backup"
date=$(date +"%d-%b-%Y")
# Set default file permissions
umask 177
# Dump database into SQL file
mysqldump --user=$user --password=$password --host=$host $db_name >$backup_path/$db_name-$date.sql

# Delete files older than 30 days
find $backup_path/* -mtime +30 -exec rm {} \;


#DB backup log
echo -e "$(date +'%d-%b-%y  %r '):ALERT:Database has been Backuped"    >>/var/log/DB_Backup.log
Last update:
04-09-2017 10:16
Author:
Karl Hudgell
Revision:
1.0
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Latest FAQs RSS

  1. Useful Notes (13-11-2019 12:51)
  2. Dockerized Download VM (30-01-2019 20:26)
  3. Jmeter + Performance Plugin + Jenkins Pipeline (16-02-2018 12:49)
  4. MySQL DB Backup Script (04-09-2017 10:16)
  5. Replace Cabin Filter (20-02-2017 13:45)