首页 > 解决方案 > mariabackup:空备份文件

问题描述

我正在尝试在 CentOS 7.5 上自动备份 MariaDB Server 10.2.15 中的一些 mysql 数据库:

mariabackup --backup --target-dir=/srv/db_backup --databases="wordpress" --xbstream | \ 
openssl enc -aes-256-cbc -k mysecretpassword > \ 
$(date +"%Y%m%d%H").backup.xb.enc

我期望的是一个/srv/db_backup名为的文件$(date +"%Y%m%d%H").backup.xb.enc

我找到的是$(date +"%Y%m%d%H").backup.xb.enc在我的主目录中调用的文件大小为 0 的文件,该/srv/db_backup目录如下所示:

[root@wordpressdb1 ~]# ls -la /srv/db_backup/
total 77868
-rw-------  1 root root    16384 Jul 31 14:30 aria_log.00000001
-rw-------  1 root root       52 Jul 31 14:30 aria_log_control
-rw-------  1 root root      298 Jul 31 14:30 backup-my.cnf
-rw-------  1 root root      938 Jul 31 14:30 ib_buffer_pool
-rw-------  1 root root 79691776 Jul 31 14:30 ibdata1
-rw-------  1 root root     2560 Jul 31 14:30 ib_logfile0
drwx------  2 root root       19 Jul 31 14:30 wordpress
-rw-------  1 root root      103 Jul 31 14:30 xtrabackup_checkpoints
-rw-------  1 root root      458 Jul 31 14:30 xtrabackup_info

运行 mariabackup 命令的所有进一步尝试均失败:

mariabackup: Can't create/write to file '/srv/db_backup/ib_logfile0' \
(Errcode: 17 "File exists")
mariabackup: error: failed to open the target stream for 'ib_logfile0'.

我做错了什么?

编辑 第一个错误是 openssl -aes-256-cbc 中缺少破折号

现在我看到了:

180731 15:18:37 Executing FLUSH NO_WRITE_TO_BINLOG TABLES...
Error: failed to execute query FLUSH NO_WRITE_TO_BINLOG TABLES: Access \
denied; you need (at least one of) the RELOAD privilege(s) for this operation

我已将 SUPER 和 RELOAD 都授予 root 用户,但仍然出现此错误。

标签: mariadbcentos7database-backups

解决方案


您需要使用--stream=xbstream,而不是--xbstream

您备份到目录,而不是流中。


推荐阅读