Even though I'm late for the feast, still, here is the recipe, and I believe it's a practical method, with some preconditions.
The core idea is telling the server to move the objects in a particular location (which of course is in one Samba share) to another location (which of course is in another Samba share).
inotifywait
is the chef, with the cookers called while
, read
, and mv
. That's the team for our dinner.
And the kitchen (or maybe dinning room) looks like this:
Samba shares
├─share.1
│ ├─recv
│ ├─to.share.2
│ ├─to.share.3
│ └─[...]
├─share.2
│ ├─recv
│ ├─to.share.1
│ ├─to.share.3
│ └─[...]
├─share.3
│ ├─recv
│ ├─to.share.1
│ ├─to.share.2
│ └─[...]
└─[...]
A user login to, let's say, share.x. If the user wants to move/copy something inside share.x to share.y, here is the operation:
Pick the objects inside share.x, move/copy them to share.x/to.share.y
.
The server is monitoring those to.share.*
folders with inotifywait
, thus it knows it's time to work.
The server moves the objects inside share.x/to.share.y
to share.y/recv
.
Done!
The preconditions include, a particular folder structure as above, a job/service/script run on the server to do the real mv
operation.
I do have my own script code to share with you, but there're a lot of improvements to make:
inotifywait -m "$source_dir" --format '%w%f' -e moved_to,create,modify |
while read file; do
mv -v "$file" "$dest_dir";
done
Modify those $source_dir
and $dest_dir
to fit your own need.
I use supervisor
to manage a bunch of scripts such as above to make my "Samba teleportation". If you're not familiar with supervisor
, please refer to http://supervisord.org/ and other answers about it.