Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. # Optional variables for a backup script
  2. MYSQL_USER="root"
  3. MYSQL_PASS=""
  4. DB_NAME=""
  5. BACKUP_DIR="backup"
  6.  
  7. test -d "$BACKUP_DIR" || mkdir -p "$BACKUP_DIR"
  8. # Get the database list, exclude information_schema
  9. for table in $(mysql -B -s -u $MYSQL_USER --password=$MYSQL_PASS $DB_NAME -e 'show tables')
  10. do
  11. echo $table
  12. # dump each database in a separate file
  13. mysqldump -u $MYSQL_USER --password=$MYSQL_PASS "$DB_NAME" "$table" 2> /dev/null | gzip > "$BACKUP_DIR/$table.sql.gz"
  14. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement