mysql 备份压缩
#!/bin/bash
BACKUP_TIME=`date +%Y%m%d%H%M`
BACKUP_PATH="/data/backup.files/sql"
BACKUP_FILE="$BACKUP_PATH/edatao.$BACKUP_TIME.sql.tar.bz2"
find $BACKUP_PATH -iname "*.sql.tar.bz2" -type f -mtime +10 -exec rm {} ;
mysqldump --skip-lock-tables -h 127.0.0.1 -uuser_name -puser_pass dbname | bzip2 > $BACKUP_FILE
mysql 压缩文件导入:
for file.sql.gz
zcat /path/to/file.sql.gz | mysql -u 'root' -p your_database
For bzip2 compressed files (.sql.bz2), use:
bzcat <file> | mysql -u <user> -p <database>
or
pv <file> | bunzip2 | mysql -u <user> -p <database>