Get the App
SLTechnology News&Howtos  ›  Database  › 

Mysqldump compressed backup export import (including periodic backup shell scripts)

Shulou Source: shulou.com Published: 2022-06-01 06:45:54 10月02日 Update

The mysqldump tool comes with an option that does not compress the exported backup file. You can use only one command to compress the exported file in combination with gzip, as follows:

Mysqldump compressed export:

# mysqldump-h292.168.0.3-P3306-uroot-ppwd123-- single-transaction-- default-character-set=utf8-R-E zabbix-- log-error=zabbix2018030709.log | gzip > zabbix2018030709.sql.gz

Parameter explanation:

-h official DB IP

-P official DB Port

-u official DB account

-p official DB account matching password

-R derives the storage process and function

-E leads to events

-- single-transaction transaction consistency score

-- default-character-set character set, which is consistent with the official db character set

-- log-error error log files. If a backup error occurs, only the files are empty, and the error words are written in the memory.

Zabbix Export DB name

Import after mysqldump compression export:

# gunzip 'zabbix'$FILENAME.sql.gz

Find / data/dbbak/zabbix*.gz-mtime + 7-exec rm-f {}\

Find / data/dbbak/zabbix*.log-mtime + 7-exec rm-f {}\

# crontab-e

300 * sh / data/dbbak/zabbixdbbak.sh 1 > / data/dbbak/zabbixdbbakcron.log 2 > > / data/dbbak/zabbixdbbakcron.bad

Tags: Files consistency characters character sets backups consistency events transactions functions parameters commands tools methods interpretations scripts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info vpn Shulou Information Xiaomi macOS