Discussion:
[unison-users] need write only / behave like rsync
Benoît-Pierre DEMAINE benoit@demaine.info [unison-users]
2017-03-24 18:44:17 UTC
Permalink
Hello.

Like all of us here, I am sharing a folder between several computers. Say,
server S, and clients A and B. The folder contains a commfon folder all
systems can read and write, and some folders only some hosts can alter.

All the sync is done by root.

Here is a typical sync command:

$uver -auto -batch $options -times -prefer $SRC -addversionno $SRC ssh://roo
t@${host}//$DST

Where uver is unison-2.48 or unison-2.40, depending on the client. This
command is run by root in cron. Version to use is determined earlier by
script. This allows me to use unison in a network where some machines can
have v40 only, and other, v48 only.

The first issue I had in the past, but, should be fixed now with this
command line, is how to respect owners of files. I had some troubles when
user ***@A owns some files, and dhp does not exists on B: first sync S-A
imports file from A to S, and on S, file is owned by dhp. Then, I sync
S-B, the file is sent to B, dhp does not exist, file is owned by root. On
next S-B sync, i have either a critical sync error, or, unison resolves
the conflict by deciding that file will be owned by root, and, changes
owner to root on S. Next sync, propagates this change on A: file which
used to be created by dhp is now owned by root; dhp can't alter it
anymore. Should the above line be fine on this aspect ?

Second problem I am having today. Now consider I have two servers S1 and S2:

The folder will contain data that only servers can change, and, data only
some clients can change. Every one will always have at least read only
right on everything. All hostwill have write permissions on folder
locally; but, in some cases, if a host locally alters some files, I want
unison to revert data to the server version.

/s will be a folder that S1 ans S2 can change; any change on any machine
will be propagated to the other server, as unison usually does.This folder
will also be propagated to all clients, but if a client alters it's local
copy, unision must revert the server version.

Then, with similar concept, each client will have a "personnal folder",
/a, /b ... that only this client can change; other clients will receive
the folder from the server; but if B alters /a, the server shall reject
the modification, and force things that are stored in S. For these
folders, I would like unison to behave like rsync would do.

-noupdate /folder ... does not do it. if A creates file /a/foo, and server
propagates it to B, and B modifies or modifies /a/foo, then, the server
will refuse to import changes from B to S. But, if B creates /a/bbb, then,
S will import that new file; and I want this to be impossible. Also, if A
creates /a/aaa, and B modifies /a/aaa, that file will not be reverted to
the original version from A.

If I try to use rsync before unison: rsync can fix most of my issues, but
if B alters a file just after rsync fixed it, unison may import a
corrupted file.

Is there an option to force unison to override remote folders using server
version ... for some folders ?

If not, I will have to ask unison to ignore /a and /b, and sync them via
rsync.

*****************************

Here is an example: server created tmp/d, and client modified it. Conflict
comes up. But dispite -prefer /srv/doublehp unison will leave the client
with it's recent version, as long as the file on client is more recent
than the one on server:

# unison-2.48 -auto -batch -times -prefer /doublehp -noupdate /doublehp
/doublehp ssh://***@client//doublehp
Contacting server...
Connected [//server//doublehp -> //client//doublehp]
Looking for changes
Waiting for changes from server
Reconciling changes
<=?=> deleted tmp/d
local : unchanged file modified on 2017-03-24 at 17:01:14 size
0 rw-r--r--
client : deleted
<=?=> changed tmp/z
local : unchanged file modified on 2017-03-24 at 17:46:00 size
2 rw-r--r--
client : changed file modified on 2017-03-24 at 17:46:18 size
2 rw-r--r--
No updates to propagate
Synchronization complete at 17:54:17 (0 item transferred, 2 skipped, 0
failed)
skipped: tmp/d (would update a file with noupdate or noupdatepartial set)
skipped: tmp/z (would update a file with noupdate or noupdatepartial set)


In this case, rsync would not mind, and just push the server version.
--
o_/ DEMAINE Benoît-Pierre (aka DoubleHP) http://benoit.demaine.info/
If computing were an exact science, IT engineers would'nt have work \_o<

"So all that's left, Is the proof that love's not only blind but deaf."
(FAKE TALES OF SAN FRANCISCO, Arctic Monkeys)
Alan Schmitt alan.schmitt@polytechnique.org [unison-users]
2017-03-29 11:41:19 UTC
Permalink
Hello,
Post by Benoît-Pierre DEMAINE ***@demaine.info [unison-users]
Is there an option to force unison to override remote folders using
server version ... for some folders ?
Have you considered the forcepartial option? It seems to do exactly what
you want.

Best,

Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-02: 406.42, 2016-02: 404.04
Alan Schmitt alan.schmitt@polytechnique.org [unison-users]
2017-04-02 09:51:48 UTC
Permalink
Hello Benoît-Pierre,

I'm responding back on the list, as I think this is a question about
path specification.

To sum up for the list: is there a way to have a forcepartial for all
files at a given path, except for some of them?

Maybe we need to implement a forcepartialnot, similar to ignorenot


Alan
Post by Alan Schmitt ***@polytechnique.org [unison-users]
Hello,
Post by Benoît-Pierre DEMAINE ***@demaine.info [unison-users]
Is there an option to force unison to override remote folders using
server version ... for some folders ?
Have you considered the forcepartial option? It seems to do exactly what
you want.
Best,
Alan
Thanks, yes it does what I need. Almost.
But I have a glitch.
Say, I want to sync etc local tmp. Tmp will be sync the normal way
(classic unison). Etc will be sync the forced way. local contains several
subfolders; most of the must be sync forced way using server version,
except one, which I want to be sync the normal unison way; I have not
found how to do it yet, and found only this workaround which ... is not
exactly what I want: (let's make example simple)
src="/foo/"
unison -forcepartial "BelowPath etc -> $src" -forcepartial "BelowPath
local/bar -> $src" -forcepartial "BelowPath etc -> $dst" "$src" "$dst"
NOTE: when using belowpath, the path on the left of -> MUST NOT end with a
trailing slash, or the string will be ignored. I have seen some people in
blogs and forums using Path foo/* ... which is usually the bad way to do
things, as it will match only single files.
So, my problem in the above line is that if unison server modifies
/foo/local/bar/* ... these modifications will be canceled on next sync. I
want to use the force option for /foo/local, except for /foo/local/bar
which shall work the normal unison way. I want my server to be able to
alter /foo/local/bar.
Running unison twice with different arguments may lead to race issues.
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
Monthly Athmospheric CO₂, Mauna Loa Obs. 2017-02: 406.42, 2016-02: 404.04
Benoît-Pierre DEMAINE benoit@demaine.info [unison-users]
2017-04-03 10:46:32 UTC
Permalink
Post by Alan Schmitt ***@polytechnique.org [unison-users]
Hello,
Post by Benoît-Pierre DEMAINE ***@demaine.info [unison-users]
Is there an option to force unison to override remote folders using
server version ... for some folders ?
Have you considered the forcepartial option? It seems to do exactly what
you want.
Best,
Alan
After private discussion, we have found three solutions:

1: add a new option to unison: forcenot. Remove a subdir from the force
rule, and let this subdir use the policy of the parent folder.

2: <<-forcepartial "BelowPath $path -> $SERVER">> for subdirectory, and
<<-forcepartial "BelowPath $path -> $CLIENT">> for the sub-sub directory.
This is not exactly what I want.

3: run unison twice: first time, normal behaviour, for the sub-sub
directory, and, second time with ignore on the sub-sub dir. This would
globally do what I need, but requires two passes. Also, ignore requires
fine tuning

The official documentation lacks examples on the correct syntax. Took me
hours to understand how to write properly this part:
-forcepartial "BelowPath $path -> $SERVER"
and I am lucky my path never contains any space ...
--
Post by Alan Schmitt ***@polytechnique.org [unison-users]
o_/ DEMAINE Benoît-Pierre (aka DoubleHP) http://benoit.demaine.info/
If computing were an exact science, IT engineers would'nt have work \_o<

"So all that's left, Is the proof that love's not only blind but deaf."
(FAKE TALES OF SAN FRANCISCO, Arctic Monkeys)
Loading...