Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
klevze committed Jan 2, 2018
0 parents commit ea8c91e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# backupSQL
24 changes: 24 additions & 0 deletions backupSQL
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

TIMESTAMP=$(date +"%F")
BACKUP_DIR="/path/to/backup/sql/"
CONFIG_FILE="client.cnf"
MYSQL="/usr/bin/mysql"
MYSQLDUMP="/usr/bin/mysqldump"

datum=`/bin/date +%Y%m%d`

databases=`$MYSQL --defaults-extra-file=$CONFIG_FILE -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`

for db in $databases; do
echo "Backuping database: " $db
$MYSQLDUMP --defaults-extra-file=$CONFIG_FILE --single-transaction --force --opt --databases ${db} | gzip > "$BACKUP_DIR$db-${datum}.sql.gz"
done

### Remove files older than 30 days ###
#for file in "$( /usr/bin/find $BACKUP_DIR -type f -mtime +30 )"
#do
# rm $file
#done

exit 0
4 changes: 4 additions & 0 deletions client.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[client]
user = backuper
password = password
host = 127.0.0.1

0 comments on commit ea8c91e

Please sign in to comment.