WSL using Rsync to fix lazy

  • So here's the breakdown - our users complain that too much work gets completed too quickly and that they can't keep on top of it moving all of the completed work off of our production shares. (it's a long drawn out conversation).

    Anyways' with WSL you can setup a Windows Scheduled Task to call a bash script to use Rsync. This has worked well in my testing on my laptop.

    What Rsync doesn't do is actually delete directories, so I end up with a bunch of empty directories from the source. This is a bit annoying.

    I could of course, call a separate script to delete everything under the source, but this raises little flags in my head what if someone else is moving things by the time the Rsync operation is done - files would be deleted.

    That obviously isn't ideal, so my goal is to get to ZERO on the source only once Rsync has completed for what was there when it ran.

    Looking for ideas so I can test on my system here.

  • Here's the answer if anyone else is looking for it.

     rsync -avrt --ignore-existing --remove-source-files /mnt/c/Users/DBeuerle/Desktop/Path /mnt/c/Users/DBeuerle/Desktop/Archive/ && \
     rsync -av --delete `mktemp -d`/ /mnt/c/Users/DBeuerle/Desktop/Path

    Now to test around and see if this will work as expected on production.


  • Obviously the paths would change based on where they actually live and since I want this to live outside of an individual user, pointing to the user paths would make no sense in a production case.

    Also on WSL, if you go into /mnt you can get a list of all of the disks that are mounted on your Workstation/Server.
    In the case of my workstation I only have the 1 disk, so only c is listed. Severs would likely have other drives.