Skip to content

Commit bfaff60

Browse files
committed
WIP MDEV-14992 BACKUP SERVER
This introduces a basic driver Sql_cmd_backup and storage engine interfaces. On Windows, we pass a target directory name; elsewhere, we pass a target directory handle. TODO: Fully implement the storage engine interfaces. TODO: Implement locking. innodb_log_recovery_start: Make settable, for incremental backup. Alas, the space.get_create_lsn() < checkpoint logic does not work yet.
1 parent a65676f commit bfaff60

77 files changed

Lines changed: 891 additions & 65 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libmysqld/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
166166
../sql/opt_hints.cc ../sql/opt_hints.h
167167
../sql/opt_trace_ddl_info.cc ../sql/opt_trace_ddl_info.h
168168
../sql/sql_path.cc
169+
../sql/sql_backup.cc
169170
${GEN_SOURCES}
170171
${MYSYS_LIBWRAP_SOURCE}
171172
)

mysql-test/collections/buildbot_suites.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ innodb,^
66
versioning,^
77
plugins,^
88
mariabackup,^
9+
backup,^
910
roles,^
1011
auth_gssapi,^
1112
mysql_sha2,^
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BACKUP SERVER TO '$datadir/some_directory';
2+
ERROR HY000: Incorrect arguments to BACKUP SERVER TO
3+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
4+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
5+
ERROR HY000: Can't create directory 'MYSQLTEST_VARDIR/some_directory' (Errcode: 17 "File exists")
6+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';

mysql-test/main/backup_server.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--let $datadir=`select @@datadir`
2+
--error ER_WRONG_ARGUMENTS
3+
evalp BACKUP SERVER TO '$datadir/some_directory';
4+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
5+
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
6+
--error 21
7+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
8+
--rmdir $MYSQLTEST_VARDIR/some_directory
9+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
10+
--rmdir $MYSQLTEST_VARDIR/some_directory
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
CREATE USER user1@localhost IDENTIFIED BY '';
2+
connect con1,localhost,user1;
3+
BACKUP SERVER TO 'some_directory';
4+
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
5+
disconnect con1;
6+
connection default;
7+
GRANT SELECT ON test.* TO user1@localhost;
8+
connect con1,localhost,user1;
9+
BACKUP SERVER TO 'some_directory';
10+
ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
11+
disconnect con1;
12+
connection default;
13+
GRANT RELOAD ON test.* TO user1@localhost;
14+
ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
15+
GRANT RELOAD ON *.* TO user1@localhost;
16+
connect con1,localhost,user1;
17+
BACKUP SERVER TO 'some_directory';
18+
ERROR 42000: Access denied; you need (at least one of) the SELECT privilege(s) for this operation
19+
disconnect con1;
20+
connection default;
21+
GRANT SELECT ON *.* TO user1@localhost;
22+
connect con1,localhost,user1;
23+
BACKUP SERVER TO '$datadir/some_directory';
24+
ERROR HY000: Incorrect arguments to BACKUP SERVER TO
25+
disconnect con1;
26+
connection default;
27+
DROP USER user1@localhost;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--source include/not_embedded.inc
2+
CREATE USER user1@localhost IDENTIFIED BY '';
3+
--connect con1,localhost,user1
4+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
5+
BACKUP SERVER TO 'some_directory';
6+
--disconnect con1
7+
--connection default
8+
GRANT SELECT ON test.* TO user1@localhost;
9+
--connect con1,localhost,user1
10+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
11+
BACKUP SERVER TO 'some_directory';
12+
--disconnect con1
13+
--connection default
14+
--error ER_WRONG_USAGE
15+
GRANT RELOAD ON test.* TO user1@localhost;
16+
GRANT RELOAD ON *.* TO user1@localhost;
17+
--connect con1,localhost,user1
18+
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
19+
BACKUP SERVER TO 'some_directory';
20+
--disconnect con1
21+
--connection default
22+
GRANT SELECT ON *.* TO user1@localhost;
23+
--connect con1,localhost,user1
24+
--let $datadir=`select @@datadir`
25+
--error ER_WRONG_ARGUMENTS
26+
evalp BACKUP SERVER TO '$datadir/some_directory';
27+
--disconnect con1
28+
--connection default
29+
DROP USER user1@localhost;

mysql-test/main/mysqld--help.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,7 @@ performance-schema-max-socket-classes 10
20562056
performance-schema-max-socket-instances -1
20572057
performance-schema-max-sql-text-length 1024
20582058
performance-schema-max-stage-classes 170
2059-
performance-schema-max-statement-classes 227
2059+
performance-schema-max-statement-classes 228
20602060
performance-schema-max-statement-stack 10
20612061
performance-schema-max-table-handles -1
20622062
performance-schema-max-table-instances -1

mysql-test/mariadb-test-run.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ END
180180
main-
181181
archive-
182182
atomic-
183+
backup-
183184
binlog-
184185
binlog_encryption-
185186
binlog_in_engine-
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATE TABLE t(i INT PRIMARY KEY) ENGINE=INNODB;
2+
INSERT INTO t VALUES(1);
3+
BEGIN;
4+
DELETE FROM t;
5+
connect backup,localhost,root;
6+
BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
7+
disconnect backup;
8+
connection default;
9+
COMMIT;
10+
SELECT * FROM t;
11+
i
12+
ibdata1
13+
mysql
14+
test
15+
undo001
16+
undo002
17+
undo003
18+
# restart
19+
SELECT * FROM t;
20+
i
21+
DROP TABLE t;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--source include/have_innodb.inc
2+
3+
CREATE TABLE t(i INT PRIMARY KEY) ENGINE=INNODB;
4+
INSERT INTO t VALUES(1);
5+
BEGIN;
6+
DELETE FROM t;
7+
8+
--connect backup,localhost,root
9+
evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory';
10+
--disconnect backup
11+
--connection default
12+
13+
COMMIT;
14+
SELECT * FROM t;
15+
16+
let $datadir=`SELECT @@datadir`;
17+
--source include/shutdown_mysqld.inc
18+
--list_files $MYSQLTEST_VARDIR/some_directory
19+
#--rmdir $datadir
20+
#--move_file $MYSQLTEST_VARDIR/some_directory $datadir
21+
--rmdir $MYSQLTEST_VARDIR/some_directory
22+
--source include/start_mysqld.inc
23+
24+
SELECT * FROM t;
25+
DROP TABLE t;

0 commit comments

Comments
 (0)