Moving files from cache using a mv/cp script?


Jaster

Recommended Posts

I have a share (lets call it Source) which is set to 'use cache: yes'. Once the mover runs, it is moved to the array.

Sometimes I use scrips to move files around across shares; e.g. (mv /mnt/user/Source/foo.img /mnt/user/Destination/bar.img).

Destination is set up not to use the cache, but if the script runs while the file is located on the cache, it will end creating a Folder called "Destination" on the cache and moving the file there. Resulting in an orphaned File :(

How do I prevent that, or what kind of scripting do I have to use here?

Link to comment

Linux sees all user shares as being mounted on the same device, so when you try to move from one to the other it just renames it so it has a different path. You can copy the files instead of moving then it will use the settings of the destination share to decide where to put the file, and then you can delete it from the source.

Link to comment
1 hour ago, Jaster said:

I see the point, but 90% of the time moving is correct as the files are on the array. So creating that kind of overhead seems not correct and takes way longer.

Maybe I could add a check if the file(s) are still on the cache? No idea if/how it is possible.

Why not set the 'Destination' to also have Cache=Yes?     That way the move of a file that is on the cache will be virtually instantaneous, and later mover will move it to the array.

 

One thing that might help you if you want to be clever is to utilise the fact that /mnt/user0 only shows files that are on the main array, while /mnt/user shows files that are on the array or the cache.   Any difference would imply a file that is only on the cache.  Also there is nothing to stop you checking /mnt/cache which is a direct reference to the physical cache drive by-passing the User Share level.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.