How to sync only one file type with Unison?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: RPG Blues Looping
--
Chapters
00:00 How To Sync Only One File Type With Unison?
00:16 Accepted Answer Score 8
00:26 Answer 2 Score 0
01:23 Thank you
--
Full question
https://superuser.com/questions/383376/h...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#unison
#avk47
ACCEPTED ANSWER
Score 8
You need to add the following lines to your profile:
ignore = Name ?*
ignorenot = Name *.jpg
ANSWER 2
Score 0
Eight years later ... the accepted doesn't properly ignore files with no period, or dotfiles.
And any pattern (say, Regex ^((?!.jpg).)*$
) that does matche these will also gobble directories that might have .jpg as a child. (See "Unison starts detecting updates..." under Ignoring Paths in the manual.)
The only way I've found is to let the sync proceed with those extra files included, and then use
find "$DEST" --type f ! -iname "*.jpg" -delete
find "$DEST" --type d -empty -delete
to kill them, and then clean up the empty directories. (In my case, I actually did
find "$DEST" --type d -empty ! -name ".stfolder" -delete
to preserve a SyncThing marker directory--don't ask.)
A potentially bad consequence of this is copying lots of extra data for a short time--in my case, some 3.5GB moves from one partition to another, and then is promptly deleted.