All Projects → quickshiftin → Mysqlbkup

quickshiftin / Mysqlbkup

Licence: lgpl-3.0
Lightweight MySQL backup script in BASH

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Mysqlbkup

VestaCP-Sync-Backups-To-Mega
VestaCP: uploading backups to the MEGA cloud
Stars: ✭ 17 (-86.82%)
Mutual labels:  backup, cron
aws-tag-sched-ops
Retired, please see https://github.com/sqlxpert/lights-off-aws
Stars: ✭ 24 (-81.4%)
Mutual labels:  backup, cron
butdr
Backup to Cloud( Google Drive, Dropbox ... ) use rclone
Stars: ✭ 49 (-62.02%)
Mutual labels:  backup, cron
btrfs-backup
A simple, flexible script for versioned backups using btrfs and rsync
Stars: ✭ 59 (-54.26%)
Mutual labels:  backup, cron
docker-backup-to-s3
Docker container that periodically backups files to Amazon S3 using s3cmd and cron
Stars: ✭ 124 (-3.88%)
Mutual labels:  backup, cron
Roam To Git
Automatic RoamResearch backup to Git
Stars: ✭ 489 (+279.07%)
Mutual labels:  cron, backup
pgsql-backup
PostgreSQL Backup Script. Ported from AutoMySQLBackup.
Stars: ✭ 24 (-81.4%)
Mutual labels:  backup, cron
Automation-using-Shell-Scripts
Development Automation using Shell Scripting.
Stars: ✭ 41 (-68.22%)
Mutual labels:  backup, cron
emsm
A lightweight, easy to extend minecraft server manager.
Stars: ✭ 72 (-44.19%)
Mutual labels:  backup, cron
Restic Systemd Automatic Backup
My restic backup solution using Backblaze B2 storage, systemd timers (or cron) and email notifications on failure.
Stars: ✭ 314 (+143.41%)
Mutual labels:  cron, backup
Bash Toolkit
Este proyecto esá destinado a ayudar a los sysadmin
Stars: ✭ 13 (-89.92%)
Mutual labels:  cron, backup
Dottask
Simple and easy go task framework, support loop & cron & queue
Stars: ✭ 124 (-3.88%)
Mutual labels:  cron
Eye
Eyewitness.io package for Laravel 5 applications
Stars: ✭ 114 (-11.63%)
Mutual labels:  cron
Crontabmanager
PHP library for GNU/Linux cron jobs management.
Stars: ✭ 113 (-12.4%)
Mutual labels:  cron
Cookie Quick Manager
An addon to manage (view, search, create, edit, remove, backup, restore) cookies on Firefox.
Stars: ✭ 111 (-13.95%)
Mutual labels:  backup
Discord Guild Copy
A script to copy a discord guild/server
Stars: ✭ 127 (-1.55%)
Mutual labels:  backup
Backup Manager
Database backup manager for dumping to and restoring databases from S3, Dropbox, FTP, SFTP, and Rackspace Cloud
Stars: ✭ 1,589 (+1131.78%)
Mutual labels:  backup
Butler
Export/Import Jenkins jobs & plugins 📤
Stars: ✭ 113 (-12.4%)
Mutual labels:  backup
Helicopterizer
Backup and Restore for Docker Container!
Stars: ✭ 112 (-13.18%)
Mutual labels:  backup
Dapr Demos
Collection of personal Dapr demos (bindings, state, pub/sub, service-to-service invocation)
Stars: ✭ 109 (-15.5%)
Mutual labels:  cron

mysqlbkup

Lightweight MySQL backup script to backup all your MySQL databases every night.

In a matter of minutes you can setup nightly backups of your MySQL databases on any Linux server with mysqldump and standard GNU utilities.

Instructions

  1. Download the package
  2. Run the installer via sudo - sudo ./install
  3. Configure database and backup parameters (see Configuration below)
  4. Setup a CRON job (see CRON below)

Configuration

Database Settings

These are configured in /etc/mysqlbkup.cnf. Editing this file is similar to /etc/my.cnf.

There are sensible defaults for mysqldump parameters, but you may adjust them to your needs.

Backup Settings

These are configured in /etc/mysqlbkup.config

$BACKUP_DIR - The directory where backups are written

$MAX_BACKUPS - Number of backups per database (default 3)

Compression Settings

These are configured in /etc/mysqlbkup.config

$BKUP_BIN - The binary used to compress mysqldump files

$BKUP_EXT - The extension used for compressed backup files

The default compression program is gzip and the default extension is .gz. You may change these to any program and extension you wish, in which case take note the various examples below will have different extensions accordingly.

Database filter Setting

These are configured in /etc/mysqlbkup.config

$DB_EXCLUDE_FILTER - Filter to exclude databases from the backup (see Excluding databases from backup below)

CRON

The cron is simple, just schedule it once per day.

Here we redirect STDOUT to a log file and STDERR to a separate log file.

## mysql backups --------------------------------------
1 2 * * * /usr/local/bin/mysqlbkup.sh 1>> /var/log/mysqlbkup.log 2>>/var/log/mysqlbkup-err.log

What it does

The script will create directories beneath $BACKUP_DIR, named after the database. Beneath there, gzip files are created for each day the database is backed up. There will be at most $MAX_BACKUPS backup files for each database.

/var/db-backups/my_db/
2013-02-10-my_db.sql.gz  2013-02-11-my_db.sql.gz  2013-02-12-my_db.sql.gz

Retrieving a backup

Just drill down into the directory of the database you desire to restore (or copy to another location). Take the prior example for instance. Suppose you wish to unpack it in your home directory and view the contents of the database. You simply copy and gunzip the file.

# Copy the database backup to your home directory
cp /var/db-backups/my_db/2013-02-12-my_db.sql.gz ~
# Unpack the database
gunzip ~/2013-02-12-my_db.sql.gz

At this point ~/2013-02-12-my_db.sql is available as a normal plain text SQL file.

Restoring a backup

Restore an unzipped SQL file:

mysql -h [host] -u [uname] -p[pass] [dbname] < [backupfile.sql]

Restore a zipped SQL file:

gunzip < [backupfile.sql.gz] | mysql -h [host] -u [uname] -p[pass] [dbname]

Excluding databases from backup

The filter string is space-separated list of entries that indicate databases to exclude. You may do an exact match such as

DB_EXCLUDE_FILTER='my_db'

By default excluding filter entries use BASH pattern matching. So you might test for a prefix in the database name with a filter like this

DB_EXCLUDE_FILTER='wp_*'

If BASH pattern matching isn't good enough for some reason, you may alternatively use POSIX regular expressions by prefixing your entry with a tilde. For example

DB_EXCLUDE_FILTER='~.*_test'

Again, these are space-separated entries and you can mix and match, so to include all 3 of the examples in one filter

DB_EXCLUDE_FILTER='my_db wp_* ~.*_test'

Requirements

mysql & mysqldump as well as GNU versions of the following programs date, gzip, head, hostname, ls, rm, tr, wc

If you override gzip using the $BKUP_BIN option, the binary you choose must be installed and will be checked during script execution.

Dry Run

To test the script's configuration you may invoke it passing 'dry' as the first argument.

mysqlbkup.sh dry
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].