Skip to content

Instantly share code, notes, and snippets.

@techbyvideo
Last active May 26, 2019 08:51
Show Gist options
  • Save techbyvideo/fb10f83c1a1bb939adb8be4c8d5281df to your computer and use it in GitHub Desktop.
Save techbyvideo/fb10f83c1a1bb939adb8be4c8d5281df to your computer and use it in GitHub Desktop.

Revisions

  1. techbyvideo revised this gist Aug 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion scriptBackup.sh
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@ for SQL in $LISTEBDD

    do

    if [ $SQL != "information_schema" ] && [ $SQL != "mysql" ] && [ $SQL != "performance_schema" ]; then
    if [ $SQL != "information_schema" ] && [ $SQL != "mysql" ] && [ $SQL != "performance_schema" ] && [ $SQL != "Database" ]; then

    ## backup database
    mysqldump -uroot -p'techbyvideo' $SQL > ${SQL}_`date +"%Y-%m-%d"`.sql
  2. techbyvideo created this gist Aug 26, 2016.
    30 changes: 30 additions & 0 deletions scriptBackup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/bash

    #Backups Folder
    cd /backups/mysql/

    # Get list of databases
    LISTEBDD=$( echo 'show databases' | mysql -uroot -p'techbyvideo' )

    # Save the current date
    DATE=`date +%y_%m_%d`

    ##List of databases
    for SQL in $LISTEBDD

    do

    if [ $SQL != "information_schema" ] && [ $SQL != "mysql" ] && [ $SQL != "performance_schema" ]; then

    ## backup database
    mysqldump -uroot -p'techbyvideo' $SQL > ${SQL}_`date +"%Y-%m-%d"`.sql

    ## Compress file tar.bz2
    tar jcf ${SQL}_`date +"%Y-%m-%d"`.sql.tar.bz2 ${SQL}_`date +"%Y-%m-%d"`.sql

    ## delete backups
    rm ${SQL}_`date +"%Y-%m-%d"`.sql

    fi

    done