8

I have a directory ~/x7/music/sfx.
There are some files and folders in the root of ~/x7/music.
I need to sync only the sfx folder and ignore anything else in music.

I've tried many variants, but all of them was wrong.

ignore = Name music/*
ignorenot = Regex music/sfx/.* (OR just *)

does not work.

I was expecting to use something like

ignore = Name music/*^/
Melebius
  • 6,183
  • 4
  • 39
  • 52
det
  • 81
  • 1
  • 3

3 Answers3

1

I'm not familiar with unison, but to ignore everything except sfx you could use

ignore = Regex /root/path/to/music/.*
ignorenot Regex /root/path/to/music/sfx/.*

Documentation Source

There is also an ignorenot preference, which specifies a set of patterns for paths that should not be ignored, even if they match an ignore pattern. However, the interaction of these two sets of patterns can be a little tricky. Here is exactly how it works:

  • Unison starts detecting updates from the root of the replicas—i.e., from the empty path. If the empty path matches an ignore pattern and does not match an ignorenot pattern, then the whole replica will be ignored. (For this reason, it is not a good idea to include Name * as an ignore pattern. If you want to ignore everything except a certain set of files, use Name ?*.)

  • If the root is a directory, Unison continues looking for updates in all the immediate children of the root. Again, if the name of some child matches an ignore pattern and does not match an ignorenot pattern, then this whole path including everything below it will be ignored.

  • If any of the non-ignored children are directories, then the process continues recursively.

Will Barnwell
  • 4,049
  • 21
  • 34
  • unfortunately, your solution is not working properly. It still syncing all music folder. I cannot sync only this folder, because unison support 2 sources (in example remote and local) so i can use only regex for this specific operation. – det Jul 11 '16 at 07:16
  • i looked at their docs, where they explain how to do this, and updated my answer – Will Barnwell Jul 12 '16 at 13:16
  • _Thank you for trying to help)_ This string: `ignore = Regex /home/det/x7/music/((?!sfx).)*` or (~./x7/music...) tells **error**: `Fatal error: File "x7", line 33: Malformed pattern "Regex /home/det/x7/music/((?!sfx).)*".` – det Jul 13 '16 at 14:15
  • Updated to use ignorenot – Will Barnwell Jul 13 '16 at 18:24
1

Following unison's documentation, if a certain path is ignored then so does everything bellow it. So, if you want to ignore everything within a folder except a subfolder, you should not ignore the folder itself, but everything inside it (which is different), and then use ignorenot.

ignore = Path x7/music/?*
ignore = Path x7/music/.?*
ignorenot = Path x7/music/sfx

That should do it.

Regarding the particular regexs used there, I'm following once again unison's documentation advice: "For this reason, it is not a good idea to include Name * as an ignore pattern. If you want to ignore everything except a certain set of files, use Name ?*." The second ignore line ignores also hidden files/folders within music, if that's necessary for you.

gusbrs
  • 123
  • 1
  • 7
0

On 2.48.3, this should work:

ignore = Path /root/path/to/music/*
ignorenot = Path /root/path/to/music/sfx
southp
  • 494
  • 1
  • 4
  • 14