@@ -923,7 +923,7 @@ static bool copy_or_move_file(const char *src_file_path,
923923 ds_ctxt_t *datasink = ds_data; /* copy to datadir by default */
924924 bool ret;
925925
926- /* File is located outsude of the datadir */
926+ /* File is located outside of the datadir */
927927 char external_dir[FN_REFLEN ];
928928
929929 if (Fil_path::type_of_path (dst_file_path) == Fil_path::absolute) {
@@ -1298,20 +1298,27 @@ Myrocks_checkpoint::file_list Myrocks_checkpoint::data_files() const {
12981298 return Myrocks_datadir (checkpoint_dir).data_files ();
12991299}
13001300
1301- static void par_copy_rocksdb_files ( const Myrocks_datadir::const_iterator &start,
1302- const Myrocks_datadir::const_iterator &end ,
1303- size_t thread_n, ds_ctxt_t *ds,
1304- bool *result) {
1301+ static void par_copy_or_move_rocksdb_files (
1302+ const Myrocks_datadir::const_iterator &start ,
1303+ const Myrocks_datadir::const_iterator &end, size_t thread_n, ds_ctxt_t *ds,
1304+ bool *result) {
13051305 for (auto it = start; it != end; it++) {
13061306 if (ends_with (it->path .c_str (), " .qp" ) ||
13071307 ends_with (it->path .c_str (), " .lz4" ) ||
13081308 ends_with (it->path .c_str (), " .zst" ) ||
13091309 ends_with (it->path .c_str (), " .xbcrypt" )) {
13101310 continue ;
13111311 }
1312- if (!copy_file (ds, it->path .c_str (), it->rel_path .c_str (), thread_n,
1313- FILE_PURPOSE_OTHER , it->file_size )) {
1314- *result = false ;
1312+ if (xtrabackup_copy_back) {
1313+ if (!copy_file (ds, it->path .c_str (), it->rel_path .c_str (), thread_n,
1314+ FILE_PURPOSE_OTHER , it->file_size )) {
1315+ *result = false ;
1316+ }
1317+ } else {
1318+ if (!move_file (ds, it->path .c_str (), it->rel_path .c_str (), ds->root ,
1319+ thread_n, FILE_PURPOSE_OTHER )) {
1320+ *result = false ;
1321+ }
13151322 }
13161323 if (!*result) {
13171324 break ;
@@ -1944,7 +1951,8 @@ bool copy_incremental_over_full() {
19441951 bool result = true ;
19451952 std::function<void (const Myrocks_datadir::const_iterator &,
19461953 const Myrocks_datadir::const_iterator &, size_t )>
1947- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &result);
1954+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
1955+ &result);
19481956
19491957 par_for (PFS_NOT_INSTRUMENTED , rocksdb.files (), xtrabackup_parallel, copy);
19501958 }
@@ -2445,7 +2453,8 @@ bool copy_back(int argc, char **argv) {
24452453 using std::placeholders::_3;
24462454 std::function<void (const Myrocks_datadir::const_iterator &,
24472455 const Myrocks_datadir::const_iterator &, size_t )>
2448- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2456+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2457+ &ret);
24492458
24502459 if (rocksdb_wal_dir.empty ()) {
24512460 par_for (PFS_NOT_INSTRUMENTED , rocksdb.files (" " , " " ), xtrabackup_parallel,
@@ -2479,7 +2488,8 @@ bool copy_back(int argc, char **argv) {
24792488 using std::placeholders::_3;
24802489 std::function<void (const Myrocks_datadir::const_iterator &,
24812490 const Myrocks_datadir::const_iterator &, size_t )>
2482- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2491+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2492+ &ret);
24832493
24842494 par_for (PFS_NOT_INSTRUMENTED , rocksdb.wal_files (" " ), xtrabackup_parallel,
24852495 copy);
0 commit comments