Skip to content
This repository has been archived by the owner on Aug 29, 2022. It is now read-only.

rm foo.txt not synced to host #16

Open
normanlolx opened this issue Feb 6, 2018 · 5 comments
Open

rm foo.txt not synced to host #16

normanlolx opened this issue Feb 6, 2018 · 5 comments

Comments

@normanlolx
Copy link
Contributor

normanlolx commented Feb 6, 2018

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:

  1. $ git clone https://gist.github.com/leymannx/277095bcc750300e749d5ae185181b74.git bg-sync
  2. $ cd bg-sync
  3. $ docker-compose up -d (wait until done)
  4. $ touch foo.txt
  5. $ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "touch bar.txt"
  6. Confirm both files exist in both locations:
    1. $ ls
    2. $ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "ls"

Now delete the files:

  1. Again inside the bg-sync folder from step 1. on the host: $ rm foo.txt
  2. $ docker exec -it -w /var/www/myapp bgsync_web_1 bash -c "rm bar.txt"
  3. Confirm that bar.txt still exists on the host but both files are removed from the container:
    1. $ ls
    2. $ 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.

@normanlolx normanlolx changed the title rm foo.txt not synced on host rm foo.txt not synced to host Feb 6, 2018
@cweagans
Copy link
Owner

cweagans commented Feb 6, 2018

Huh. That's interesting. Not sure what I can do about it though. Sounds like a Unison bug.

@dj95
Copy link

dj95 commented Feb 19, 2018

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 :)

@normanlolx
Copy link
Contributor Author

@dj95 Wow Thanks! How exactly do you access the log files?

@dj95
Copy link

dj95 commented Feb 19, 2018

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.

@weitzman
Copy link

weitzman commented Jun 7, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants