Mac/OS X launchd example

Hello. I’m just getting started setting up the GUI version on duplicacy on OS X. I’m already relatively familiar with the CLI version on Linux.

I’m trying the backup /Users on a machine with multiple users. Do to permissions issues running duplicacy as root seems best. What I’m unsure about is how to make sure it’s always running, no matter what user is or isn’t currently logged it. I’ve seen some mention of using launchd, but no specific examples.

I’m also wondering if the GUI is launched with launchd is the menubar available to all users for checking status - or am I essentially running the cli version headless? So all backup status monitoring needs to happen via logs?

Does anyone have an example setup they can share?

Have you tried using search (top right, 3rd icon) and searching for “launchd”?

Right now i got multiple hits, and one of them is


which has a launchd example.

I’m not very knowledgeable in MacOS to help more than this, but maybe the creator of that example could help us. @saspus, do you have any ideas how to handle multi-user backup?

I use launchd and the CLI version on my mac. Yeah- it took a long time to figure it out. :slight_smile:

My run script for duplicacy is called run_backups

now…
go to ~/Library/LaunchAgents and make a file like this:

com.kevinv.run_backups.plist (yeah… and mac is supposed to be “easy”) …:slight_smile:

Here is a copy of the contents of my file

<?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>com.kevinv.run_backups</string>

  <key>ProgramArguments</key>
  <array>
    <string>/Users/kevinv/Documents/Software/Duplicacy/run_backups</string>
  </array>

  <key>Nice</key>
  <integer>1</integer>


  <key>StartCalendarInterval</key>
  <dict>
    <key>Hour</key>
    <integer>23</integer>
    <key>Minute</key>
    <integer>15</integer>
  </dict>


  <key>RunAtLoad</key>
  <false/>

  <key>StandardErrorPath</key>
  <string>/Users/kevinv/Documents/Software/Duplicacy/run_backups.err</string>

  <key>StandardOutPath</key>
  <string>/Users/kevinv/Documents/Software/Duplicacy/run_backups.out</string>
</dict>
</plist>

Then to get it going you type LaunchCtl load com.kevinv.run_backups.plist

See? it is just as easy as good ole cron! HA HA HA

2 Likes

Yep, you can just follow the same setup, except for location of the repository and launchd plists that need to be on the system/all users scope. That same setup still works fine on my Mac.

To summarize: you create a plist describing recurring task for launchd daemon which simply runs duplicacy backup in the repository located under /Users.

Important is location for your plist, if you want it to run for all users don’t put it to ~/Library/... Instead, put it under /Library/LaunchDaemons/. From the man page:

~/Library/LaunchAgents Per-user agents provided by the user. /Library/LaunchAgents Per-user agents provided by the administrator. /Library/LaunchDaemons System-wide daemons provided by the administrator. /System/Library/LaunchAgents Per-user agents provided by OS X. /System/Library/LaunchDaemons System-wide daemons provided by OS X.

How to create launchd plist? Choose one:

So, to summarize,

Under /Users/.duplicacy/ I’ve put all the files that have to do with the duplicacy. Including the launchd plist and ssh private key for my SFTP destination.

I then just symlink-ed the plist to the correct place for launchd:

sudo ln -s /Users/.duplicacy/com.saspus.duplicacy.plist /Library/LaunchDaemons/com.saspus.duplicacy.plist
2 Likes

todotbp: make a wiki of this!

So, just to recap for people searching in the future. It looks like most people are using the CLI version via launchd and not the GUI version.

I was hoping to get the GUI feedback for any logged in user while still running as root, and according to schedule - but it looks like unattended CLI in the background is the way to go.

Thanks for the pointers everyone!

You can now also mark a reply as the solution to your question. (Just activated that feature for the support category)

Just realized that I did in fact write a small walkthrough last year that includes the sample filter list for MacOS.
Linking it here, for what it is worth – feel free to use content for wiki. It’s pretty much what I use today.

2 Likes