Unison File Synchronizer docker container


lionceau

Recommended Posts

Hello, I'm new to unraid and still in my evaluation/trial phase. So far I'm very humbled by the functionality and ease of use compared to my Mac Mini homeserver running OS X.

 

One service that I depend on is Unison, a CLI file synchronisation service very similar to rsync but faster and with better conflict management.

 

On my current (non-unraid) server I use unison with a ssh for secure file syncing. It's fast, full-featured, stable, cross platform and much more dependable than syncthing, Bittorrentsync/Resilio and comparable apps that I've tried.

 

https://www.cis.upenn.edu/~bcpierce/unison/

 

I couldn't find anything related to Unison in the Community App program. There's an image on dockerhub but that's for a different purpose and doesn't include SSH.

 

Where do I begin setting up a personalised Docker container for this?

The developer is no longer adding features, only occasional maintenance fixes, so updates to unison are rare. That shouldn't make it too hard to maintain it for myself.

Or alternatively is there a way to pay a developer to create a unison template for unraid?

 

If all else fails I could make a ubuntu VM for unison but as I understand it docker is a "cleaner" solution with less overhead.

 

Another question related to Docker: I keep reading that unraid is not meant to face the internet because it wasn't designed with security in mind.

I understand this. Does this recommendation also affect services running inside docker containers or is the docker abstraction sufficient to make the service secure enough to face the internet?

 

 

 

Link to comment
  • 2 months later...

I would love to have this functionality as well.  I use unison to sync data between 3 PCs in the house.... ironically enough I only use unRaid for media, and not any of my critical data.  This, of course, has led to data sprawl, having it in multiple PCs....   My goal would be to move my critical data to unRaid, and have unRaid synced to the PCs.

 

Link to comment
  • 1 month later...
14 minutes ago, MrCrispy said:

I'd never heard of Unison till now, thanks. You said its more dependable than syncthing, can you elaborate?

 

I see some dockers like https://github.com/onnimonni/docker-unisonhttps://hub.docker.com/r/clesch/ssh-unison/, you could ask Squid to add them to CA, or make a template, maybe there's a guide somewhere?

 

You can download dockers from docerhub. Searching for Unision in the apps tab, then when noting comes up, look in the middle of the screen for the button that say "Get more results from DockerHub"

Link to comment

I was able to get Unison running, but did not use a docker container.  I followed this thread:

It seems to work fine.  I did have an issue unmounting drives last week, which appeared to go away after I killed the Unison process running on unRaid, but still have to determine if that is the actual cause of the issue. 

 

Link to comment
  • 5 months later...

So I am revisiting this.  Some time ago I managed to get Unison working (syncing from PC to Unraid), but there was an issue-  Basically I could not shut down unraid unless I telneted over to unraid and manually killed the Unison process.  This to me is not really a good solution.

 

So I started investigating how to install Unison in a docker container.  In combination with the LimeTech Docker "user guide", I tried this:

https://github.com/vikduf/docker-unison, since I could find the template repository it was under (https://github.com/vikduf/docker-templates)

But when creating the container, I received an error stating it was out of date.

 

So I found this:  https://github.com/leighmcculloch/docker-unison   Unfortunately, I can't find it in a template repository, which deviates from the LimeTech Docker "user guide."  Not knowing any details about Docker, I am lost as how to proceed, and don't want to mess up unraid array.

 

Once installed, I know how to use unison... I just can't figure out how to get it installed.

 

Anyone willing to tackle this, or provide some pointers?   Thanks!

 

Link to comment
  • 5 months later...

Thank you for the recommendation.  I will look a little deeper.  Seems like it requires me to build another server.

 

I continue to use Unison, as it has been my go-to for years keeping multiple PCs in sync, with primary data on a local PC.  (unRaid is used for movie storage, which I do not consider to be all that critical).  I would like to migrate ALL data over to UNRAID, and keep it refreshed on a weekly basis through UNISON (as I do with my other PCs).

Link to comment

Great information.  I will check it out when I get some time.

But for now, Unison appears to be working.  It is not running in a docker container-  Just as a process that starts up at boot time.  In a prior version of Unraid, I needed to manually kill the unison process on the unraid server as it was hanging up the shutdown process.  That doesn't appear to be an issue anymore.

Link to comment
  • 1 year later...

Hi All, 

I saw this (I know its older), and had just worked on getting unison running in a container, but using SSH as the transport instead of the native TCP support.  The reason for your issue with "hanging" the umount is because running unison as the server process keeps active connections.  

 

The Dockerfile below will build a container that can run unison, but via an SSH connection.  It assumes a couple of things:

  1. Only 1 SSH user, and that user has a public key based auth.
  2. Only sync of one path from the container, "mounted" as a volume from the host
  3. The UID/GID values of the user are all synced between the unison client, container, and host.  This isn't strictly required.

To build this, just run "docker build -t unison-ssh ." in the directory with your public ssh key and the Dockerfile. Note, you should change the username, UID, and GID values as needed.

 

FROM ubuntu:16.04

# Override the UID/GID values, because we need these to line up with the host's file system
ENV USERUID=1000 USERGID=100 USERNAME=blah

# Get us an updated OS and intall SSH
RUN apt-get update && apt-get install -y openssh-server
RUN mkdir /var/run/sshd

# Install unison application
RUN apt-get install unison

# Random root password 
RUN NEW_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) && echo 'root:${NEW_PASS}' | chpasswd

# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd

# Create my user
RUN useradd --uid 1000 --gid 100 --no-user-group --create-home $USERNAME && mkdir /home/$USERNAME/.ssh && chown $USERUID:$USERGID /home/$USERNAME/.ssh
COPY --chown=$USERUID:$USERGID id_rsa.pub /home/$USERNAME/.ssh/authorized_keys

# Create the place we're going to get our external sync storage from
RUN mkdir /data && chown $USERUID:$USERGID /data
VOLUME /data

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.