xtrabackup version: 2.4
mysql version: docker mysql5.7
step 1: backup
innobackupex --defaults-file=~/.my.cnf.bak --user=root --password="123456" --databases=kk --backup /data/backups/
step 2: start a new mysql
docker run -d --name=mysqltt -p 3307:3306 \
-e TZ=Asia/Shanghai \
-e MYSQL_ROOT_PASSWORD=123456 \
-v /alidata1/mysql_multi/data3307/mydata:/var/lib/mysql \
mysql:5.7 --character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
step 3: apply-log
innobackupex --apply-log --redo-only /data/backups/2023-08-07_15-29-16/
step 4: restore
docker stop mysqltt
rm -rf /alidata1/mysql_multi/data3307/mydata/*
innobackupex --copy-back --datadir=/alidata1/mysql_multi/data3307/mydata/ /data/backups/2023-08-07_15-29-16/
step: start mysqltt
docker start mysqltt
the error
2023-08-07 16:04:18+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2023-08-07 16:04:19+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2023-08-07 16:04:19+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.36-1debian10 started.
2023-08-07 16:04:19+08:00 [Note] [Entrypoint]: Initializing database files
2023-08-07T08:04:19.211882Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-08-07T08:04:19.213398Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2023-08-07T08:04:19.213431Z 0 [ERROR] Aborting
Hello seqwait,
As per the error log docker container is trying to start with a freshly created mysql directory and it’s trying to run mysqld --initialize
2023-08-07T08:04:19.213398Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
In entrypoint scipt i found these functions:
you may found script you have by
docker exec -ti mysqltt /bin/bash
and
cat entrypoint.sh
# initializes the database directory
docker_init_database_dir() {
mysql_note "Initializing database files"
"$@" --initialize-insecure --default-time-zone=SYSTEM
mysql_note "Database files initialized"
}
and it should not be running if you have something in directory:
...
docker_setup_env() {
# Get config
declare -g DATADIR SOCKET
DATADIR="$(mysql_get_config 'datadir' "$@")"
SOCKET="$(mysql_get_config 'socket' "$@")"
# Initialize values that might be stored in a file
file_env 'MYSQL_ROOT_HOST' '%'
file_env 'MYSQL_DATABASE'
file_env 'MYSQL_USER'
file_env 'MYSQL_PASSWORD'
file_env 'MYSQL_ROOT_PASSWORD'
declare -g DATABASE_ALREADY_EXISTS
if [ -d "$DATADIR/mysql" ]; then
DATABASE_ALREADY_EXISTS='true'
fi
}
...
if [ -z "$DATABASE_ALREADY_EXISTS" ]; then
docker_verify_minimum_env
# check dir permissions to reduce likelihood of half-initialized database
ls /docker-entrypoint-initdb.d/ > /dev/null
docker_init_database_dir "$@"
mysql_note "Starting temporary server"
docker_temp_server_start "$@"
mysql_note "Temporary server started."
mysql_socket_fix
docker_setup_db
docker_process_init_files /docker-entrypoint-initdb.d/*
mysql_expire_root_user
mysql_note "Stopping temporary server"
docker_temp_server_stop
mysql_note "Temporary server stopped"
echo
mysql_note "MySQL init process done. Ready for start up."
echo
else
mysql_socket_fix
fi
fi
exec "$@"
Could you please check if you have files in and also if mysql directory is there database
/alidata1/mysql_multi/data3307/mydata/
also you may inspect entrypoint.sh for more info
Regards,
Denis Subbota.
Managed Services, Percona.
Hello @seqwait,
innobackupex
is an extremely old and dead tool. What modern documentation did you read to use this tool instead of xtrabackup
?
1 Like