Skip to content

Instantly share code, notes, and snippets.

View nikkanetiya's full-sized avatar

Nikunj Kanetiya nikkanetiya

View GitHub Profile
@nikkanetiya
nikkanetiya / db_backup.sh
Created August 17, 2017 05:25 — forked from willvincent/db_backup.sh
Intended for use with cron. This script will backup all (or one specific) database, the specified user has access to on the given DB server, and remove backups older than the specified duration to keep them for. If no params are passed, defaults will be used. and backups created for _every_ database.
#!/bin/bash
USAGE="$0 [-u <user> -p <password> -h <host> -P <PORT> -d <database> -D <destination/directory/without/trailing/slash>]"
DESTINATION=`pwd`
USER=root
PASS=root
HOST=localhost
PORT=3306
# SPECIFY HOW LONG TO RETAIN BACKUPS