I'm using rsync to move files uploaded on an extern system to a internal system. However I recently had someone upload two different files with the same name. Meaning they had a file from Month1 and one from Month2, but both were named mylog.csv.
I'm currently moving them between directories with rsync, which sees the change and overwrites the prior upload.
rsync -rutv --remove-source-files /external/intake/ /internal/intake/
The external path does contain additional sub-directories, ie:
/external/intake/project/user/(additional directories they may build while uploading files)
What I would like to do is timestamp files as they are moved between directories. This way I would at least see that there were two of them if they were copied over with the copy time stamp. If I could get a result something like 20201009:0800-mylog.csv
and 202001009:0810-mylog.csv
. The full path after the move would be something like:
/external/intake/project/user/(possible additional directories)/$time-file.txt
rsync does not support and hooks or renaming structures, but I think you have several options.
Option 1 -- pure rsync
If you're willing to change your output format slightly, you could create a new directory for every move, with a timestamp. When you have something like
You could sync to it by doing something like
rsync -rutv --remove-source-files /external/intake/ /somedir/newtime --link-dest="/somedir/oldtime" --compare-dest="/somedir/oldtime"
. The resulting structure would beBecause of the links, you don't have to have any extra disk usage, so you avoid quickly exploding size, but it is a bit different than what you requested exactly.
Option 2 -- bash
This will perform exactly as you asked, but it won't use rsync. You'll miss out on the speed-ups related to rdiff, but since you're not really using it for that, it shouldn't effect anything.
Here's a short bash script that should do as you require. It should duplicate behavior exactly as you asked.
Its pretty ugly, but it works. For what its worth, this is just a skeleton. I tested it in very limited cases, and ensure it works all the way before using.