Skip to content

Instantly share code, notes, and snippets.

@brianredbeard
Last active August 26, 2019 22:04
Show Gist options
  • Save brianredbeard/8321479 to your computer and use it in GitHub Desktop.
Save brianredbeard/8321479 to your computer and use it in GitHub Desktop.

Revisions

  1. brianredbeard revised this gist Jan 8, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions db_dump.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash
    # Simple script to dump the contents of a database into separate files in the directory "/backups/"
    # Symlink into /etc/cron.daily/ or add to crontab
    # Originally from: https://gist.github.com/brianredbeard
    # /usr/local/scripts/db_dump


  2. brianredbeard created this gist Jan 8, 2014.
    10 changes: 10 additions & 0 deletions db_dump.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    #!/bin/bash
    # Simple script to dump the contents of a database into separate files in the directory "/backups/"
    # /usr/local/scripts/db_dump


    #mysqldump -x --add-drop-table --all-databases > /backups/mysqldb-`date +%F-%I%p`.sql

    /usr/bin/mysql --defaults-extra-file=/root/.my.cnf -e 'show databases' | /bin/awk '{print $1}' | /bin/grep -v "^Database$" | /usr/bin/xargs -i{} /usr/bin/mysqldump --defaults-extra-file=/root/.my.cnf --opt -Q -r /backups/{}-`date +%F-%I%p`.sql {}

    gzip -q /backups/*.sql