Linux server - multiple users with multiple instances


Paul Pianta

Recommended Posts

Hi I'm trying to figure out the best way to setup sync on my home linux server so all 4 members of the family have an 'always on' client ready to receive syncs from each persons phone, tablet and pc.

My idea is to have 4 instances of sync running in parallel so they all get their own web-gui as well to help with setup and maintenance. Once the instances are running 24/7 (and configured to sync to folders in user's own home directory) then any time one of us opens sync on a device like my phone - it syncs the photos to the linux server. i would then do some manual pruning and moving files i really want to keep to a separate folder for backup on a raid disk. Moving the files would also then ensure they get cleaned off the source device.

Does that make sense or is there a way better way of doing it?

The problem I'm having is knowing how to run 4 separate instances - ideally using systemd to auto start them at boot - and how/if to get those instances to run with 4 different users.

Any help would be appreciated :)

Link to comment
Share on other sites

You could run the docker container of resilio sync on each machine (linux) or the regular  Windows, MAC clients. I find the docker solution elegant and very simple to replicate on other linux clients. 

From my docker-compose.yml file

 

 resilio-sync:
    image: linuxserver/resilio-sync
    container_name: resilio-sync
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Toronto
      - UMASK_SET=022 #optional
    volumes:
      - /docker/resilio-sync/config:/config
      - /docker/resilio-sync/cache:/downloads
      - /home/pi/sync:/sync
    ports:
      - 8888:8888
      - 55555:55555
    restart: unless-stopped

Let me explain the volumes:

volumes:
      - /docker/resilio-sync/config:/config  #main program dir where config info is stored on local disk outside of the container
      - /docker/resilio-sync/cache:/downloads # cache dir for partial downloads
      - /home/pi/sync:/sync # a shared folder gets stored here. You create "myshare" and it would then have a path of "/home/pi/sync/myshare"

Why not run an rsync cron to synchronize/mirror to your RAID array? Or something such as rsnapshot?  Backup is accomplished using rsnapshot to save it to a software raid array on a daily basis. so all my backups are automated, and up to four months old at any point. 

Multitple users: You can do this with the Family key, you could then decide on the folder type that would be shared across your users. I have a single user case with multiple windows, linux and android clients, so I have my always on Pi hosting a shared folder.

I am not sure about removing the source files once you have moved them to your RAID array... Perhaps someone else can comment on that? 


 

Link to comment
Share on other sites

Oh, and for ease of use with Linux rsync mv cd and cp commands, I suggest that you refrain from using spaces in your directory names. :)
 

pi@pi4:/ $ tree -L 2 /docker
/docker
├── calibre-web
│   └── config
├── deluge-pia
│   └── config
├── doku
│   └── config
├── plex
│   ├── config
│   ├── plexignore
│   └── plexignore-tempplate
└── resilio-sync
    ├── cache
    └── config

11 directories, 2 files

Another elegant solution might be to mount your RAID array using nfs and store the server "resilio-sync" directory right on the RAID drive. 

Link to comment
Share on other sites

Setting up multiple instances is definitely possible somehow. But I imagine this to be difficult, since of course all references have to be adjusted manually and accordingly. I think an adapted administration is better. Resilio is a client tool and not a user tool. If Resilio is installed on a server, it is a server tool and has to be looked after by an admin like all other tools on it.

I don't know of any such or similar tool that has user control and thus user accounts that allow individual settings.

The issue of performance is also important to consider, because not only does every instance take away resources, but also every file and directory because everything has to be managed. In this respect, I would consider setting up multiple instances.

Link to comment
Share on other sites

I am running several resilio sync instances in parallel on my Ubuntu 20.04 home server.  But it is in configuration mode without a WebUI.

The setup is as follows (as root):

Setup an account for each user on your home server. You can disable login if you don't want these users to login onto you server by changing "bin/bash" to "/bin/false" for the specific user in the /etc/passwd file.

I assume that sync directories for each user are under its home directory. But you can also have them elsewhere.

Make the necessary sync directories under each user home folder like mkdir /home/<username>/pictures and mkdir /home/<username>/music and ensure that they are owned by the user (i.e. chown <username>:<username> /home/<username/pictures).

For each instance generate a dedicated system service unit file /usr/lib/systemd/system/resilio-<username>.service

[Unit]
Description=Resilio Sync service <username>
Documentation=https://help.resilio.com
After=network.target network-online.target

[Service]
Type=forking
User=<username>
Group=<username>
UMask=0002
Restart=on-failure
PIDFile=/data/user/<username>/.btsync/sync.pid
ExecStart=/usr/bin/rslsync --config /etc/resilio-sync/<username>.json
ExecStartPost=/usr/bin/sleep 1
 
[Install]
WantedBy=default.target

 

For each instance generate a dedicated resilio sync config file /etc/resilio-sync/<username>.json

{
  "device_name": "<servername>-<username>",
  "storage_path" : "/home/<username>/.btsync",
  "pid_file" : "/home/<username>/.btsync/sync.pid",
  "listening_port" : 40932,      // <- define a different port for each instance
  .....                          // <- other configuration as needed 
  "webui" :
  {
  },
  "shared_folders" :             // <- add entries for each folder you want to share
  [
    {
      "secret" : "XXXXXXXXXXXXXXXXXXXXXXXXXXX",
      "dir" : "/home/<username>/pictures",
      .....                      <- other configuration as needed 
    },
    {
      "secret" : "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY",
      "dir" : "/home/<username>/music",
      .....                      <- other configuration as needed 
    }
  ]
}

If you want to use the WebUI for more flexible configuration you have to remove the entries in the "shared_folders" section and add entries to the "webui" section. especially for 

    "listen" : "0.0.0.0:8888"      // <- use dedicated port for each instance/user

you have to use dedicated ports for each user so that each has its own WebUI. You my also have dedicated login credetinals for each user.

I assume you could also work without a resilio sync config file by using the command line options of rslync (i.e. --storage <path>,  --identity <user name>, --webui.listen <IP>:<port>) if you don't need additoonal special configuration (see https://help.resilio.com/hc/en-us/articles/204762449-Guide-to-Linux-and-Sync-peculiarities).

 

Link to comment
Share on other sites

Wow thanks everybody for your great advice.

I was about to bite the bullet and start learning docker - but then jayjay just explained exactly what I originally had in mind - so I think I'm gonna go with that and then over the holidays I'll figure out docker and see if I can get that working with multiple instances.

What a great community!!

Link to comment
Share on other sites

  • 2 months later...
On 11/28/2020 at 3:07 PM, eltopo said:

Just create different config files, and run different instances of rslsync with  --config config_file. Make sure you configure different webui port, storage_path,  shared_folders, etc. for each instance.

use rslsync --dump-sample-config to create config file to start with.

Thanks! I wonder if this is possible for Windows also ...

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.