MacOS / OSX service installation


#21

Thanks, Jon. I guess i could have been more clear…

This is happening on 3 different macs. But I’m doing it the same way on all three, so I’m not surprised it is consistent…

Prior to installing the plist files, I created multiple duplicate jobs. I ran them a couple of times and they worked as expect.

I then added the plist files and restarted the machine. When I logged in, I noticed the icon had an X in it. When i clicked open in the icon, the webpage did not chow any jobs scheduled. I expected to see the ones I had created/run before.

Here is where things are not always consistent. Some times, if I select quit in the icon, I can then launch the duplicate app and things work as expected-- the icon shows up without the X and the webpage shows my expected job. Other times, after selecting quit in the icon, I cannot launch the duplicati app-- nothing happens.

I only have the 2 duplicati related plist files:

  1. net.duplicati.server.plist in /Library/LaunchDaemons/
  2. net.duplicati.tray-icon.plist in /Library/LaunchAgents
    They are unmodified from the the ones linked above.

Above you mention different user logins. The 2 plists are owned by root. They have the same owner, group, and permissions as the other plists in their respective directories. The user that I’m logging in as when I try running a backup is not root.

When it is working (after I logged in, quit the one that auto started, and relaunched the duplicati app), the following processes are running SUCCESSFULLY:

As root:
Duplicati Server Duplicati.Server.exe --webservice-port=8200
/bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati-server --webservice-port=8200

As user:
Duplicati Duplicati.GUI.TrayIcon.exe
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Applications/Duplicati.app/Contents/Resources/OSXTrayHost/osx-trayicon-rumps.py
/bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati

Is which jobs it is running tied to the tray icon? So now it is running the user jobs where as before the tray icon (I think) was running at root so it was looking for root jobs?
Just speculating… Maybe going down a rabbit hole…

Appreciate the help


#22

Nope, I think you’re on the right track.

I’m a bit rusty on this (and don’t have access to a Mac to test) so somebody please correct me if I’m misremembering…

Basically, Duplicati as tray-icon ONLY stores things in ~/.config/Duplicati (so user specific) while Duplicati as a service /daemon stores things in /root/.config/Duplicati (or possibly /private/var/root/.config/Duplicati/).

If you look in those folders you should see (among other things):

  • dbconfig.json (list of jobs)
  • Duplicati-server.sqlite (Duplicati global settings & logs)
  • ABCDEFGHIJ.sqlite (job specific settings & logs)

So assuming you have NOTHING you care about in the service / daemon “version” you should be able to copy the files out of ~/.config/Duplicati to /root/.config/Duplicati and things should work as expected.

Note that if it DOES work, you might want to either consider deleting the user-specific ~/.config files OR running in that mode and renaming a job to something like “You are in user mode - go find service mode!”.


#23

Little long… Trying to explain my understanding and make sure I get it…

I understand that things are stored in ~/.config/Duplicati

If I run normal (launching the app myself as a user), it would store my jobs in ~user/.config/Duplicati. If the plists are owned by root, and they launch duplicati at startup, they would look for my jobs in ~root/.config/Duplicati. Obviously, they are not there, so the job list is empty. That makes sense to me.

When I run duplicate as a user, I see the following run:

$ ps aux |grep -i duplica
st                 567   0.0  0.5  4189112  39892   ??  S     8:12PM   0:01.04 /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Applications/Duplicati.app/Contents/Resources/OSXTrayHost/osx-trayicon-rumps.py
st                 499   0.0  0.6  4310468  47420   ??  S     8:12PM   0:01.72 Duplicati Duplicati.GUI.TrayIcon.exe 
st                 451   0.0  0.0  4226288   1100   ??  S     8:12PM   0:00.00 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati --hosturl="http://localhost:8200" --no-hosted-server
root               108   0.0  1.1  4498896  92644   ??  S     8:12PM   0:02.63 Duplicati Server Duplicati.Server.exe --webservice-port=8200
root               110   0.0  0.0  4299788   1100   ??  Ss    8:12PM   0:00.01 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati-server --webservice-port=8200
st                 1247   0.0  0.0  4278252    872 s000  S+    8:19PM   0:00.00 grep -i duplica

some of it is run as root and some is run my user (st).

When I run duplicati via plist owned by root at startup, all is run by root. So I’m thinking that the part that looks for the jobs is in the tray icon code <-- speculation, need to confirm. If it was run by the user, so it would look in ~user/.config/Duplicati

So, what I did was move the tray icon plist from /Library/LaunchAgents to ~/Library/LaunchAgent. That way it is run by the user. I restarted, and now I see:

st                 529   0.0  0.5  4420112  39892   ??  S     8:35PM   0:01.04 /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Applications/Duplicati.app/Contents/Resources/OSXTrayHost/osx-trayicon-rumps.py
st                 487   0.0  0.6  4391568  47420   ??  S     8:35PM   0:01.72 Duplicati Duplicati.GUI.TrayIcon.exe --hosturl="http://localhost:8200" --no-hosted-server
st                 483   0.0  0.0  4273588   1100   ??  S     8:35PM   0:00.00 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati --hosturl="http://localhost:8200" --no-hosted-server
root               169   0.0  1.1  4460196  92644   ??  S     8:35PM   0:02.63 Duplicati Server Duplicati.Server.exe --webservice-port=8200
root               100   0.0  0.0  4287788   1100   ??  Ss    8:35PM   0:00.01 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati-server --webservice-port=8200
st                 687   0.0  0.0  4267752    872 s000  S+    8:37PM   0:00.00 grep -i duplica

OK. Tray stuff is running as user, but still no luck.

I notice that when I run via startup, the the tray icon command looks like:

Duplicati Duplicati.GUI.TrayIcon.exe --hosturl="http://localhost:8200" --no-hosted-server

When I run by opening the application, it looks like:

Duplicati Duplicati.GUI.TrayIcon.exe

So i modified the plist file to remove the extra switches, restarted, and IT SORT OF WORKS!

  • The icon doesn’t have the X in it anymore.

  • When i click on the icon and select open it brings up a webpage on port 8300. Hmm-- see below

  • The webpage shows my jobs!! (In my case, I had on outstanding, so it started to run it)

  • The first time it brought up the webpage, it had this popup error-- Missing XSRF Token

  • After click OK to close the error window, I stopped my job and tried editing the configuration. When I got to the last step, clicking OK would do nothing.

  • I closed the webpage, reopened it via the icon, didn’t get the error message and was able to successfully edit the configuration

Questions I currently have:

  • Why port 8300? If I look at the Duplicati jobs running, I only see port 8200:

      $ ps aux | grep -i duplica
      st                 421   0.0  1.5  4526060 127724   ??  S     8:47PM   9:48.28 Duplicati Duplicati.GUI.TrayIcon.exe
      st                 417   0.0  0.0  4270516   1084   ??  S     8:47PM   0:00.01 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati
      root               161   0.0  0.9  4440516  73600   ??  S     8:46PM   0:02.82 Duplicati Server Duplicati.Server.exe --webservice-port=8200
      st                 778   0.0  0.0  4286184    920 s001  S+    9:01PM   0:00.01 grep -i duplica
      root               100   0.0  0.0  4279596   1100   ??  Ss    8:46PM   0:00.01 /bin/bash /Applications/Duplicati.app/Contents/MacOS/duplicati-server --webservice-port=8200
      st                 699   0.0  0.5  4427592  40288   ??  S     8:58PM   0:01.05 /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python /Applications/Duplicati.app/Contents/Resources/OSXTrayHost/osx-trayicon-rumps.py
    

If I go to 8200, it cannot connect to the server.

  • What is Missing XSRF Token? Something I need to worry about?

  • What are they switches in the plist that I removed. Are they needed?

I’m not sure if I’m doing thing correctly, or if I’m setting myself up for failure. Backups are kind of important so I want to make sure I’m doing it the right way.

I want to get this working. How are others running? What am i doing different?

Thanks in advance


#24

That’s good detective work there!

This is a bit difficult to explain, so I apologize up front if it’s a bit rambling…oh, and this all assumes default settings. :slight_smile:


Duplicati has two parts - the “server” and the client (Tray Icon / web GUI).

How (and by whom) the server is executed controls where settings and jobs are stored. So if the server is executed by root, they get stored in /root/.config/Duplicati. If the server is executed by the user, they get stored in ~/.config/Duplicati (aka /[users]/.config/Duplicati).

By default the Tray Icon client creates it’s own server - so if you run the Tray Icon as yourself, settings / jobs will come from ~/.config/Duplicati but if you sudo run the Tray Icon as root they’ll come from /root/.config/Duplicati.

Adding the --no-hosted-server parameter to the Tray Icon call tells it to attach to an existing server rather than start it’s own.

The reason you’re getting the X when attached to the root executed service / daemon is because that set of configs (in /root/.config/Duplicati) has never had a job run against it.

The reason you don’t see your jobs when attached to the root executed service / daemon is because it’s looking in /root/.config/Duplicati for settings / jobs, but the ones you created running as “USER” are stored in /USER/.config/Duplicati.

You can resolve this in a few ways, but the easiest ones are probably:

  • copy the /USER/.config/Duplicati files to /root/.config/Duplicati
  • use the --server-datafolder parameter in your /Library/LaunchAgents plist file to tell the root run server to get it’s data from /USER/.config/Duplicati (instead of the default /root/.config/Duplicat). Though personally I would not recommend this option.
  • use the --server-datafolder parameter in your ~/Library/LaunchAgent plist file to tell the user run server to get it’s data from /root/.config/Duplicati (instead of the default ~/.config/Duplicati). Note that you might run into permission issues with this option
  • run your Tray Icon as root

Note that if you want backups to run whether or not you’re logged into the machine you’ll want to attach to the service / daemon server on port 8200 by using the --no-hosted-server parameter in your user specific ~/Library/LaunchAgent plist file.


Note that the Tray Icon is NOT needed for the service / daemon process to actually run backups. You can skip the ~/Library/LaunchAgent Tray Icon plist and just manually open a browser page to localhost:8200 (that’s what I do via a browser bookmark).

The service / daemon runs before any user login stuff, so it grabs port 8200. When the user logon Tray Icon runs, if it does NOT have the --no-hosted-server parameter then it will start it’s own server. Since the default port 8200 is already in use, it will try to use port 8300. If that’s in use it will go to port 8400, then 8500, etc.


The XSRF error is a known issue with “older” versions of Duplicati. It’s not anything to worry about since it just means the web GUI client couldn’t talk to the server. Refresh the web page until the error goes away and you should be fine.


Does any of that make sense or have I just confused you more? :slight_smile:


#25

Thanks, Jon. More questions trying to understand this…

Would running this (in addition of the tray plist) as user fix my issue? It would pull jobs from my user dir.

Got it. What if I don’t run the server in the first quote, and just start this as user. It would launch its own server, right? Pointing at my home dir settings. What would I lose out on?

I tried modifying the tray plist and adding the --no_hosted_server. Had same issue as before-- no job list because it is pulling jobs from root

Right. So, do I need to run this as root? Seems if I run the server this as user I wouldn’t have this issue. If I don’t try auto starting stuff at login, and I click on the app as a user, is everything running as user?

Yep. I agree :slight_smile:

I don’t want to do this for a couple of reasons-- Mostly, I want to keep settings on a per user basis. I’d rather not mix multiple users together. Also, there may be a case where the user launches the app to edit the jobs and it may edit edit jobs in the user dir that it wouldn’t run. Also, I’m not sure if the user could edit the jobs in /root/ (is there a permission issue?). How would this work when I restore- Would the files have user ownership or root ownership?

Don’t know anything about this, but OK. I won’t do it.

Yeah, I can see possible permission issues. Don’t like this.

The easiest solution would be to add the application to my login start list. But when i do that, it opens the web browser when I log in. If I can prevent that initial web browser opening, I’d be fine. I assume that is the tray icon doing that. is there something to prevent that?


#26

Ok, quick summary time. :slight_smile:


As far as I know there’s nothing in the plist that would cause the web browser to start up when you log in. I’ve got Duplicati running on a Mac with the plists and do not experience this, so I suspect there’s something specific about your setup that’s causing this to happen.

I don’t know what I clarified earlier, but when you said “I have the two .plist files in /Library/LaunchAgents and /Library/LaunchDaemons” did you mean both plists in both places?


I didn’t realize you were wanting multiple users each to have their own backup sets and NOT be able to interact with other users. If that’s the case, then you probably don’t want to be running as root, so I’d say get ride of the ~/Library/LaunchAgents plist.

This means that each user will have their own version of the “server” running when they log in. It also means that the port number used for a user will vary depending on the order in which the log in. First user to log in gets port 8200, second user gets 8300, etc.

If the login order changes, so will the port number. So browser bookmarks won’t work well in this case and the tray icon is the “best” way to manage this.

Of course, there’s nothing STOPPING a user from hitting a different port either, so you might want to add a password to each web GUI so users can’t see what other users are backing up.

But it should be pointed out that Duplicati hasn’t really been designed for this type of “multiple users with individual jobs that can’t see either other’s setup” type of implementation. That doesn’t mean it can’t be done, just that it’s not common.


#27

This doesn’t happen when I use plists. it happens if I add the application to my login items. The same thing happens if you double click on the application-- I launches the tray, and then opens the web browser. If this just did the tray, I wouldn’t have these issues.

Sorry i wasn’t clear. I have 2 plists. Server in /Library/LaunchDaemons and tray in ~/Library/LaunchAgents :slight_smile:

I think you mean get rid of the server plist in /Library/LaunchDaemons, right? The tray plist in ~/… is being run as user, not root. The tray plist will run everything needed? OR do I need to run the server plist (as user) too?

I really just want this set up so that it runs when you log in. Same as if I double click on app when I login in-- That would launch the server just for the one user. The port may or may not change, but the tray always points to it…

Let me ask this-- If I run just the tray plist, is that all I need to do? Or do I also need to run the server plist?

Appreciate the support on this


#28

Derp. Yes, that’s what I meant. :blush:

You do NOT need to run the server plist. If you only want it to run when you log in then tray plist is enough.

I’ll try to remember to test user startup & see what happens…


#29

3 posts were split to a new topic: Mac / Firefox scheduling issue


#30

tray icon fixed with this method. Thanks JohnMikeIV


#31

Wanted to follow up on this.

I have it working-- duplicate starts up on a per user basis. It does not auto open the browser.

To do this, I added this PLIST to the ~/Library/LaunchAgents/net.duplicati.tray-icon.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>net.duplicati.tray-icon</string>
    <key>ProgramArguments</key>
    <array>
        <string>open</string>
        <string>/Applications/Duplicati.app/</string>
        <string>--args</string>
        <string>--hosturl="http://localhost:8200"</string>
<!--        <string>--no-hosted-server</string>
-->
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

No other PLIST needed.

Thanks for the support.


#32

Hi,
Thank you for the solution
I have just installed duplicati-2.0.3.3_beta_2018-04-02.dmg is this solution likely to be rolled into the .dmg?

One comment; I created the plist logged off then logged back in again but the tray icon did not appear and when I ran launctl to load it it reported that it already was loaded. starting duplicati from the application folder also did not produce a tray icon. This may be because I had run up duplicati from the applications folder prior to creating the plist?. Performing a restart of the mac resolved the problem.

regards


#33

Just to add a little note from my recent experience installing as a service, in macOS Mojave (10.14), it may be necessary, depending on what you’re backing up, to add Duplicati.app into the “Full Disk Access” folder under System Preferences --> Security & Privacy --> Privacy. For me, Duplicati didn’t have access to some important folders (like ~/Library/Mail).

To install, I followed this fellow’s instructions (minus the Homebrew installation – I just installed Mono from the project’s site), and it’s working well.

Performance-wise, the initial backup of 1TB to a local USB3 non-SSD drive (using encryption) on an i7 Macbook Pro with 16GB of RAM took about 16 hours. Subsequent runs take around 20 minutes with the “counting” process, etc. I’m not sure if that’s good or bad.

Thanks,
Mike


#34

Thanks for the input. Depending on the number of files in your source 20 min. Matt but be so bad.