dooblem/bsync

Keeping track of mount information

Closed this issue · 2 comments

As I remember from Unison, mount status of the directories (recursively) must be checked before (or even during?) synchronizing. If there is something different, I must be warned seriously (for example force user to type: "yes i know") if there is a different or missing mount entry either in localhost or remote host.

Because this problem leads unwanted erase of subfolders.

Example:
We have DIR1 and DIR2 to sync.
DIR1/aaa/bbb is mounted via sshfs from a remote machine, or with "-o bind" option from localhost.
Sync the two directories.
Umount DIR1/aaa/bbb (it is unmounted because a network/cable connection error)
Sync again: Problem.
We should be warned about that.

Hi ceremcem.
Yes, Unison has a "mountpoint" config option:
http://www.cis.upenn.edu/~bcpierce/unison/download/releases/stable/unison-manual.html#mountpoints

For now bsync do not have any config file, so it's not very easy to add.

Also, for now bsync is an interactive tool and it shows you the files to be deleted before asking you to confirm the sync. You can abort the sync there if something is wrong. It's not a serious warning though.

If syncing in one direction with rsync --delete you also get a similar behaviour : there is no mountpoint check options in rsync.

What I suggest you to do is enclosing your bsync call in a simple wrapper script doing some checks and exiting if something is wrong. Some examples:

#!/bin/sh -e
# with a remote directory

mountpoint /dir1/mounted
ssh user@host mountpoint /dir2/mounted

exec bsync /dir1 user@host:/dir2
#!/bin/sh -e
# local directories

mountpoint /dir1/mounted
mountpoint /dir2/mounted

exec bsync /dir1 /dir2
#!/bin/sh -e
# check if content in dirs (unison like preference)

[ "$(ls /dir1/mounted)" != "" ]
ssh user@host '[ "$(ls /dir2/mounted)" != "" ]'

exec bsync /dir1 user@host:/dir2

I'm closing it. Tell me if you experience problems with the wrapper scripts.