docker-bg-sync
docker-bg-sync copied to clipboard
`rm foo.txt` not synced to host
Same docker-compose.yml as in the README only added SYNC_PREFER=newer. Adding files are synced just fine in both directions. Removing files in contrast is synced in only one direction host -> container but not vice versa.
Steps to reproduce:
$ git clone https://gist.github.com/leymannx/277095bcc750300e749d5ae185181b74.git bg-sync$ cd bg-sync$ docker-compose up -d(wait until done)$ touch foo.txt$ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "touch bar.txt"- Confirm both files exist in both locations:
$ ls$ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "ls"
Now delete the files:
- Again inside the bg-sync folder from step 1. on the host:
$ rm foo.txt $ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "rm bar.txt"- Confirm that bar.txt still exists on the host but both files are removed from the container:
$ ls$ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "ls"
macOS 10.13.3 Docker for Mac (stable) 17.12.0-ce-mac49 (21995)
I guess for most people that's just OK as they are more interested to sync from the host into the container which works just fine also for removing files. Also as $ echo "bla bla bla" >> file.txt inside the container is synced still fine to the host. It's only rm that's not synced.
Huh. That's interesting. Not sure what I can do about it though. Sounds like a Unison bug.
This happens because in the default configuration the nodeletion option is set to the source (https://github.com/cweagans/docker-bg-sync/blob/master/sync.sh#L131). In the log file unison logs, that it skipped removing the file because of a nodeletion option. Overwrite the nodeletion-option with a custom setting or set the environment variable SYNC_NODELETE_SOURCE=0 in you docker-compose.yml. It's always helpful to read the log files and documentation :)
@dj95 Wow Thanks! How exactly do you access the log files?
The default unison log-file is unison.log in the users home directory which runs unison(default with your docker-compose.yml should be /root/unison.log).
With logfile = $PATH in your SYNC_EXTRA_UNISON_PROFILE_OPTS you're able to save it anywhere in your container. But be aware of setting it into one of your synced volumes because it throws a lots of errors because of a kind of race condition when unison wants to read and write the file at the same time.
Probably worth fixing this. Inside the container there can be deletions of compiled twig, css/js, etc. You dont want that bloating and confusing the IDE on the host.