title: dbfs to dbfs copy - Copying one workspace's dbfs location from current workspace
body: <p>We are having 2 different workspace i.e <code>workspace-01</code> and <code>workspace-02</code> . Now we are having the use-case like need to copy <code>dbfs</code> location of <code>workspace-01</code> into same path in <code>workspace-02</code>. For this use-case , we have written databricks cli based bash script and doing import into local , export local into another workspace-02. since Bash comment is running on driver node, this script is keep running and copying process is taking
  longer time (<code>~40</code> hrs). since <code>dbfs cp</code> command giving low performance. Is there way to handle this use-case in alternate approach ?</p>
  <pre><code>%sh
  #!/bin/bash
  start=`date +%s`
  list_dbfs_scritpt=($LOCATION_TO_BE_MIGRATED)
  var_dirname='/acedbfsscriptmigration'
  var_for_slash='/'
  var_dbfs=&quot;dbfs:&quot; 
  IFS=&quot;,&quot;
  for var_script in $list_dbfs_scritpt
  do
     echo $var_script
     echo &quot;*************************************************** &quot;
     echo &quot;Currently we are processing on cluster $var_script &quot;
     echo &quot;*************************************************** &quot;
     OUTPUT=$(dbfs  ls  $var_script --profile EXPORT_WORKSPACE_PROFILE)
     echo &quot;$OUTPUT&quot; | while IFS= read -r line ; 
     do var_source_loc=$var_script$var_for_slash$line$var_for_slash
     echo $var_source_loc
     var_base_dbpath=$(basename &quot;$var_script&quot;)
     var_base_filepath=$(basename &quot;$line&quot;)
     var_local_location_path=$var_dirname$var_for_slash$var_base_dbpath$var_for_slash$var_base_filepath
     echo $var_local_location_path
     
     if [ -d &quot;$var_local_location_path&quot; ]; then
         echo &quot;$var_local_location_path folder are existing&quot;
         rm -R $var_dirname
         mkdir -p  $var_local_location_path
       else
         echo &quot;$var_local_location_path folder is not present&quot;
         mkdir -p  $var_local_location_path
         echo &quot;$var_local_location_path folder is being created now&quot;
      fi
      
      dbfs cp -r  $var_source_loc  $var_local_location_path --overwrite  --profile EXPORT_WORKSPACE_PROFILE
      
      echo &quot;exporting process started&quot;
     
      var_final_dbfs_location=$var_source_loc
      
      dbfs  ls $var_final_dbfs_location --profile IMPORT_WORKSPACE_PROFILE &gt; /dev/null
      
      RES=$?
      if [ $RES -eq 0 ]; then
         echo &quot;WARNING : $var_source_loc folder already in target workspace and this folder will be overwritten&quot;
         dbfs rm -r  $var_final_dbfs_location  --profile IMPORT_WORKSPACE_PROFILE
         dbfs mkdirs $var_final_dbfs_location  --profile IMPORT_WORKSPACE_PROFILE
         
      else
         echo &quot;$var_source_loc folder is not present in target workspace&quot;
         dbfs  mkdirs $var_final_dbfs_location --profile IMPORT_WORKSPACE_PROFILE
      fi
      dbfs cp -r  $var_local_location_path  $var_final_dbfs_location --profile IMPORT_WORKSPACE_PROFILE
      rm -r $var_local_location_path
      echo &quot;******************end of process********************************* &quot;
     done
  done
  </code></pre>