Timeline for How to make rsync delete directories from destination that are not in the source list
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| May 28, 2019 at 4:03 | comment | added | Sparhawk | Great hack!! +1 | |
| May 28, 2019 at 3:52 | history | edited | Freddy | CC BY-SA 4.0 | added 462 characters in body |
| May 28, 2019 at 3:04 | comment | added | Jason K | As it happens, I don't think -L will work after all. After the rsync completes, the system ensures that all synced files are mode 644 and directories 755. This would mean that someone could symlink to a file they couldn't read, then after the sync, because of -L and the permission 'fixing' they would have access to the file. I'll have to think this through some more. | |
| May 28, 2019 at 2:22 | comment | added | Jason K | I think there's some promise to using -L and I will experiment with that tomorrow. Basically, I have a tool that is using rsync. One user specifies the directories that they want synced when the tool is run. A different user runs the tool that actually does the syn. The initial user can change the directory lists to be synced at any time. However, the syncing user should see the "end" result - a perfect copy with no "extra" directories. If I build a directory containing links to all the directories first, this would work. I just wish I didn't need that extra step. | |
| May 28, 2019 at 2:04 | comment | added | Sparhawk | Yeah manually rm makes more sense to me. They have to change the rsync command anyway. | |
| May 28, 2019 at 1:30 | comment | added | Freddy | Yes, that's why I thought he could create a (fake) parent directory and use symlinks instead. For the example with symlink dir12/dir2 I used rsync -aiL dir12/ dir3 and that seems to work, but I haven't done any further testing with more complex setups. But... if OP knows that dir2 will be excluded from the next sync, it might be easier to manually rm -rf the directory on the destination side. | |
| May 28, 2019 at 1:19 | comment | added | Sparhawk | The question is unclear, but I assumed that dir1 and dir2 were not necessarily in the same directory. I thought about -L, but that potentially conflicts with -a from the question. | |
| May 28, 2019 at 0:58 | history | answered | Freddy | CC BY-SA 4.0 |