@@ -927,7 +927,7 @@ static bool copy_or_move_file(const char *src_file_path,
927927 ds_ctxt_t *datasink = ds_data; /* copy to datadir by default */
928928 bool ret;
929929
930- /* File is located outsude of the datadir */
930+ /* File is located outside of the datadir */
931931 char external_dir[FN_REFLEN ];
932932
933933 if (Fil_path::type_of_path (dst_file_path) == Fil_path::absolute) {
@@ -1302,20 +1302,27 @@ Myrocks_checkpoint::file_list Myrocks_checkpoint::data_files() const {
13021302 return Myrocks_datadir (checkpoint_dir).data_files ();
13031303}
13041304
1305- static void par_copy_rocksdb_files ( const Myrocks_datadir::const_iterator &start,
1306- const Myrocks_datadir::const_iterator &end ,
1307- size_t thread_n, ds_ctxt_t *ds,
1308- bool *result) {
1305+ static void par_copy_or_move_rocksdb_files (
1306+ const Myrocks_datadir::const_iterator &start ,
1307+ const Myrocks_datadir::const_iterator &end, size_t thread_n, ds_ctxt_t *ds,
1308+ bool *result) {
13091309 for (auto it = start; it != end; it++) {
13101310 if (ends_with (it->path .c_str (), " .qp" ) ||
13111311 ends_with (it->path .c_str (), " .lz4" ) ||
13121312 ends_with (it->path .c_str (), " .zst" ) ||
13131313 ends_with (it->path .c_str (), " .xbcrypt" )) {
13141314 continue ;
13151315 }
1316- if (!copy_file (ds, it->path .c_str (), it->rel_path .c_str (), thread_n,
1317- FILE_PURPOSE_OTHER , it->file_size )) {
1318- *result = false ;
1316+ if (xtrabackup_copy_back) {
1317+ if (!copy_file (ds, it->path .c_str (), it->rel_path .c_str (), thread_n,
1318+ FILE_PURPOSE_OTHER , it->file_size )) {
1319+ *result = false ;
1320+ }
1321+ } else {
1322+ if (!move_file (ds, it->path .c_str (), it->rel_path .c_str (), ds->root ,
1323+ thread_n, FILE_PURPOSE_OTHER )) {
1324+ *result = false ;
1325+ }
13191326 }
13201327 if (!*result) {
13211328 break ;
@@ -1885,7 +1892,8 @@ bool copy_incremental_over_full() {
18851892 bool result = true ;
18861893 std::function<void (const Myrocks_datadir::const_iterator &,
18871894 const Myrocks_datadir::const_iterator &, size_t )>
1888- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &result);
1895+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
1896+ &result);
18891897
18901898 par_for (PFS_NOT_INSTRUMENTED , rocksdb.files (), xtrabackup_parallel, copy);
18911899 }
@@ -2385,7 +2393,8 @@ bool copy_back(int argc, char **argv) {
23852393 using std::placeholders::_3;
23862394 std::function<void (const Myrocks_datadir::const_iterator &,
23872395 const Myrocks_datadir::const_iterator &, size_t )>
2388- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2396+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2397+ &ret);
23892398
23902399 if (rocksdb_wal_dir.empty ()) {
23912400 par_for (PFS_NOT_INSTRUMENTED , rocksdb.files (" " , " " ), xtrabackup_parallel,
@@ -2419,7 +2428,8 @@ bool copy_back(int argc, char **argv) {
24192428 using std::placeholders::_3;
24202429 std::function<void (const Myrocks_datadir::const_iterator &,
24212430 const Myrocks_datadir::const_iterator &, size_t )>
2422- copy = std::bind (&par_copy_rocksdb_files, _1, _2, _3, ds_data, &ret);
2431+ copy = std::bind (&par_copy_or_move_rocksdb_files, _1, _2, _3, ds_data,
2432+ &ret);
24232433
24242434 par_for (PFS_NOT_INSTRUMENTED , rocksdb.wal_files (" " ), xtrabackup_parallel,
24252435 copy);
0 commit comments