MacOS / OSX service installation


#1

I’m looking to put together a how-to for shifting a Mac installation of Duplicati to a service, but the only stuff I’m finding (such as Running as a Service on Mac is so old it doesn’t work with current versions of MacOS…

Unfortunately, I’m super familiar with Macs either so I’m not sure how to build a current OS version supported .plist file to send to launchctrl (or even if such as thing is needed) - but I am willing to play around with stuff!

So if anybody has any suggestions on how to get Duplicati going as a service on more recent MacOS versions, please share - I’ll test and post it here (unless you want to do it yourself).


Mac Installation Questions
Multi user backup on OSX, possible?
(.Trashes) Failed to process metadata / Access to the path ... is denied
#2

Warning: I have not tested either of these plists yet and won’t be able to for few more hours :slight_smile: .

Try placing this plist in /Library/LauncDaemons/. Then either reboot or run sudo launchctl load -w /Library/LaunchAgents/net.duplicati.server.plist. This should start the server as root and make it accessible from the usual URL.

For the Tray Icon, you’ll need this plist in either /Library/LaunchAgents to run when any user logs in or ~/Library/LaunchAgents/ to run when only a specific user logs in. You may need to change this line:

<string>/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono</string>

if your mono installation differs (check by running which mono in Terminal)


Starting Duplicati server-wide (as root) & server-only on the Mac
#3

Awesome, thanks!

No hurry the testing, I won’t be back on my Mac until Monday. :slight_smile:


#4

For the tray-icon, I think you need to use open, otherwise it will not have the right MacOS context. The “autostart” file from the installer is here:

This should avoid the call to Mono. Also, Mono can be found at “various” places, so Duplicati ships with a launcher that can start the executables with Mono:

You can use it like this:


#5

I guess using open should take care of mono’s path. Although it seems I still need to pass --hosturl="http://localhost:8200" --no-hosted-server for it to work. I have updated net.duplicati.tray-icon.plist accordingly.


#6

I did finally test the plists which seem to work, albeit with a couple of glitches:

  • The tray icon is always in the “error” mode, except when a backup is running. Yet the Web-GUI shows no errors or warnings whatsoever
  • The “Show Log” section of the Web-GUI doesn’t show any logs, even after running a couple of backups.

I think the two could be related, but I am not certain exactly what is causing this problem.


#7

Heh. I too got around to testing today.

I found the service plist to work quite well, though in an unrelated issue I’m having permission issues between user accounts.

I didn’t have time to test the tray icon. Note that your “always error” icon might be related to a known install issue that is resolved by forcing an error (and subsequent icon reset) such as by starting then canceling a backup.


#8

I tried the net.duplicati.tray-icon.plist file in /Library/LaunchAgents but for some reason the auto-start (and manual start) tray icon is still opening to port 8300 .


#9

I thought 8200 was the default port. Why would the tray icons open to 8300? :thinking:

Did you remove the regular Duplicati autostart from System Prefs->User->Login Items?


#10

Yes, 8200 is the DEFAULT port - but when dealing with multiple “users” (including the service, if running) startup order can cause things to get messy.


#11

I understand this behaviour when multiple users are each running their own Duplicati service + tray icon; but I wonder why this would happen when there is only a single instance of the service running as the root?


#12

You are correct - if the service is the only Duplicati server running, then this wouldn’t happen as even individual users would be connecting to the same service server.


#13

If there was something using port 8200 when the instance running as root started, it will try another port, and from then on it remembers which port worked and starts with that as the first attempt.

So maybe something else was using port 8200 ?


#14

I’m having similar issues. I have the two .plist files in /Library/LaunchAgents and /Library/LaunchDaemons; both specify port 8200 and the tray-icon one specifies no-hosted-server.

However somehow I’ve ended up with my config using 8300, so when I start my system from scratch, neither localhost:8200 nor opening from the menu shows my config. I have to quit the menu and reopen Duplicati from /Applications (to launch on 8300) to see my config.

How do I get my config back on port 8200?


#15

I’d have to test but I think the issue might be that you are telling the tray-icon one (is that LaunchAgents?) both a port number (which says “use this port for your server”) AND --no-hosted-server (which says “don’t host your own server”) so it’s getting conflicting parameters.

I suspect if you quit the tray-icon (right click on it and select Quit) port 8300 will stop working but port 8200 will continue to load. This means that the daemon/service is loading first (and taking port 8200) then the tray-icon is loading TRIES for port 8200 but sees it’s in use so moves on to port 8300.


Unless you’ve already got a big backup created or a lot of jobs configured, the easiest way to shift from port 8300 (tray-icon) to port 8200 (daemon/service) is probably to export the job from one then import into the other.

I’d then suggest renaming the port 8300 job to something like “DO NOT USE” or “WRONG PORT!” - that way if this happened again you’d have a visual notice of what was going on rather than “crap, all my configs disappeared!”. If you do decide to delete the 8300 job (after confirming it works at port 8200) make sure to only delete the config. You can delete the database only if you didn’t point the port 8200 job to the old port 8300 .sqlite file. (If you do delete the database, that’s OK - it can be recreated, but it takes a while for Duplciati to chunk through every thing.

Unless you’re planning to start your backups from scratch, whatever you do, DO NOT delete the destination files as this is your already backed up content. If you delete that there’s no recovering it - you’ll just have to start your backups from the beginning again.


#16

Thank you for the response :+1:

You’re exactly right in your analysis; I tried to export my config from 8300 to 8200 but this caused problems with some of my source file paths.

However, I realise I was over-complicating things for myself. I have removed both plist files and have simply added Duplicati.app to my login items. I only have one user on this machine so this works well enough for me.

Slight disadvantage though is that this causes the browser to open at http://localhost:8200/ on login but I can live with that (perhaps an option to control this could be included in a future release).


#17

You mean when you log in your browser opens to Duplicati? If so,that’s odd as I have a similar set-up (i think) but that doesn’t happen to me…


#18

My mistake; I must have had “reopen windows on login” selected when I logged off… Didn’t happen to me just now after a restart :flushed:

As you were!


#19

Hope I can jump in this thread as I’m having a similar issue. If you want, I can create a new thread if that is better…

Summary of my issue:

  • I created the 2 plists per above and put them in the appropriate directories
  • When I start up, the icon has a X in it
  • If I select open on the open, it opens a web page (8200) but it doesn’t have any backup sets in it
  • If I try launching the app, nothing happens
  • If I try going to 8300 it can’t find anything

I originally just added the app to my start up items, but like the others, it launches the web browser upon log in. I made sure ‘reopen windows at login’ in not selected, and I even quit safari prior to logging out.

Any ideas? I assume this is working successfully for someone.

Thanks!


#20

This may not apply to you, but it is a known scenario for the icon to show the “X” if no jobs have been run yet.

What backups are you expecting to see? Did you already create some that “disappeared” when you shifted to service installation?

What “app” are you trying to open? Other than the GUI (which is the tray icon / web interface) things are pretty much all command line, so it’s possible the shell is opening, showing an error message or help screen then closing again before you can see it.

Port 8300 should only come into play if you’re running more than one instance of Duplicati, such as the service and self-serving try icon or perhaps a self-serving tray icon in two different user logins.