-
-
Save betweenbrain/6901595 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Backup database from console | |
DATABASE= | |
DEFAULTS_FILE=$DATABASE.cnf | |
BACKUP_DIR= | |
DB_OUT_FILENAME=$DEFAULTS_FILE-`date +\%Y\%m\%d`.sql.gz | |
mysqldump --defaults-extra-file=$DEFAULTS_FILE $DATABASE 2>> cron.log | gzip - > $BACKUP_DIR/$DB_OUT_FILENAME |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[client] | |
host= | |
user= | |
password= | |
database= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Truncate database tables from console | |
DATABASE= | |
DEFAULTS_FILE=$DATABASE.cnf | |
mysql --defaults-extra-file="$DEFAULTS_FILE" -Nse 'show tables' $DATABASE | while read table; do mysql --defaults-extra-file="$DEFAULTS_FILE" -e "truncate table $table" DATABASE; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment