Moving large folders around on external storage

Hi all, I just want to share my experience with moving 40GB folders on external share which is simply impossible on 8.2.7. It always ended with timeout, sooner than 3600 sec, etc. Eventually, I did it by hand:

  1. created new target folders
  2. updated oc_filecache
  3. moved subfolders on external storage, ie. on Windows server

I used this sql procedure, with source and target path as parameters:

delimiter //

create procedure rename_folder (in source varchar(255), in target varchar(255))
declare done int default false;
declare src varchar(255);
declare stor int(11);
declare tgt varchar(255);
declare cur1 cursor for select fileid from oc_filecache where path=source;
declare continue handler for not found set done=true;
open cur1;
read_loop: LOOP
fetch cur1 into src;
select storage into stor from oc_filecache where fileid=src;
select fileid into tgt from oc_filecache where storage=stor and path=target;
if done then leave read_loop; end if;
update oc_filecache set parent = tgt where parent = src;
end loop;
close cur1;

update oc_filecache set path = replace(path,source,target), path_hash = md5(replace(path,source,target)) where path like concat(source,"/%");


delimiter ;

Then I called it: CALL rename_folder("source_path","target_path");

When done, I moved all content of source folder to target folder on external server. Owncloud was put in maintenance mode during whole operation.

The content was moved and all shared links were kept and remain working.

Hope this help someone.



I was having this exact issue, thanks for sharing, will try this out:)

@dynaptis I think it would make sense to move this from "Feature Requests" into the category. There more users will notice this.

OK, moved, thank you for your suggestion.

1 Like