--备份
mkdir /usr/local/mysqlBackup /usr/local/mysql/bin/mariabackup --defaults-file=/etc/my.cnf --backup --user=root --password=‘123456‘ --port=3306 --target-dir=/usr/local/mysqlBackup/$(date ‘+%Y-%m-%d‘)_fullbackup
--备份部分数据库或表
/usr/local/mysql/bin/mariabackup --defaults-file=/etc/my.cnf --backup --databases="test_db base_db_dev.t_app_base" --user=root --password=‘123456‘ --port=3306 --target-dir=/usr/local/mysqlBackup/$(date ‘+%Y-%m-%d‘)_fullbackup
--恢复
#先将删除原目录下的数据文件 cd /usr/local/db/mysql/data && rm -rf * #恢复 /usr/local/mysql/bin/mariabackup --defaults-file=/etc/my.cnf --copy-back --datadir=/usr/local/db/mysql/data --target-dir=/usr/local/mysqlBackup/2020-09-15_fullbackup #给权限 chmod -R 777 /usr/local/db #重启MariaDB服务 service mysql restart