My folder structure is like this:
/volume1
/photoTest
/folderA
/@eaDir
/eaDir_tmp
/folderB
/@eaDir
/eaDir_tmp
/folder with space
/@eaDir
/eaDir_tmp
What I'm trying to do is copy files from each eaDir_tmp
to their respective @eaDir
folder.
I was able to get it going via:
for a in $(find /volume1/photoTest -type d -name eaDir_tmp); do rsync -vhar --chmod=a+rwx $a/ $a/../@eaDir; done;
until I hit the folder with spaces. The above script simply craps out.
After lots of googling, I tried:
find /volume1/photoTest -type d -name eaDir_tmp -print0 | xargs -0 rsync -vhra --chmod=a+rwx {} {}/../@eaDir
Dry run of this command runs without issues. But the actual run gets stuck after printing this.
sending incremental file list
@eaDir/subdir1/
And gets stuck thereon.
ps -elf | grep rsync
shows bunch of rsync processes on wait
and poll_s
state.
Does anyone have any idea what's going on? And what the solution might be? I would like to move files eventually, but trying with copy first to be less destructive if things go bad.
Also, I can get it working with 2 commands with lots of ugliness:
# first, copy all files via:
find /volume1/photo -type d -name eaDir_tmp -exec cp -a -t {}/../@eaDir {}/. \;
# second, change file permissions:
find /volume1/photo -type d -name @eaDir -exec chmod 777 {} -R \;
But this is slow and takes twice the time, not to mention is very limiting compared to what rsync can do.
Some background info:
- What's inside
eaDir
folders? More folders, and then some files inside them. If it helps, the whole thing started with this: https://github.com/mbrrg/synology-thumbgen. The author suggests to delete existing@eaDir
folders and simply renameeaDir_tmp
. But I can't do that because existing folders contains files that I'd like to keep. I can explain but I think that'll muddy the question further. - This is inside my Synology NAS, DSM 6.0+, which I think is running BusyBox? Not sure though.
- If destination files exists, then I'd like to overwrite it if source is newer. Otherwise not.