How I back up my Logic Sessions

The engineer dead if the drive don't back up • Kendrick Lamar - Savior (Interlude)

I wanted to create a way to back up my Logic Sessions as simply as possible. Eventually I’d like to incorporate an external hard drive, but for now I’m just using my MacBook’s internal hard drive and Google Drive as cloud storage. Warning up front: you’ll need some coding skills and a familiarity with the command line to pull this off. Here are the steps I’ve taken to get an initial process working!

Step 1:

Download and install Google Drive for Desktop so that you can choose which individual folders or files to sync between your hard drive and the cloud.

Step 2:

Create a folder called Logic Sessions Backup (in my case it lives at /Users/your_username/Google Drive/My Drive/Logic Sessions Backup) and choose to sync it with Google Drive for Desktop (so that you have the same copy both locally and in the cloud). There should be a cloud icon with a down arrow that you can click on to sync your local copy of the folder with Google Drive in the cloud.

Step 3:

Create a shell script that uses rsync to copy only files that have changed from ~/Music/Logic to Logic Sessions Backup/. I named it backupLogicSessions.sh, added the contents below, and ran chmod +x backupLogicSessions.sh to make sure it’s executable.

rsync does all the heavy lifting here, and adding a call to osascript for style points 💅

rsync -avu ~/Music/Logic ~/Google\ Drive/My\ Drive/Logic\ Sessions\ Backup

# -a Do the sync preserving all filesystem attributes
# -v run verbosely
# -u only copy files with a newer modification time (or size difference if the times are equal)

# could also add the following flag if you want to remove files from
# the target folder that are deleted from the source, but for
# Logic sessions, I don't want to delete any from the target backup folder

# --delete delete the files in target folder that do not exist in the source

osascript -e 'display notification "The backup is finished" with title "Success"'

MacOS comes with a version of rsync, but I kept getting an error that said Load failed: 5: Input/output error, which was reallllly unhelpful. In the end, I ran brew install rsync (for this you’ll need to have Homebrew installed) after which everything worked as expected.

Step 4:

Next, create a .plist file so we can take advantage of launchd in MacOS to automatically run backupLogicSessions.sh at a scheduled time every day. Create a file called local.backupLogicSessions.plist in the folder ~/Library/LaunchAgents, add this content and save it:

This will automatically run backupLogicSessions.sh at 1:00 PM every day.

<?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>local.backupLogicSessions</string>
	<key>ProgramArguments</key>
	<array>
		<string>sh</string>
		<string>-c</string>
		<string>"$HOME/code/backupLogicSessions.sh"</string>
	</array>
    <key>StartCalendarInterval</key>
    <dict>
        <key>Hour</key>
        <integer>13</integer>
        <key>Minute</key>
        <integer>00</integer>
    </dict>
</dict>
</plist>

A few things to note from this file:

  • We need the path to the shell script, which in my case is "$HOME/code/backupLogicSessions.sh". In this case the quotes are necessary. If you’d like to check what $HOME is for you, run echo $HOME.
  • I specified 1:00 PM (13 00) as the time when I’d like the script to run every day.
  • To manually remove the daemon from launchctl you can run launchctl unload ~/Library/LaunchAgents/local.backupLogicSessions.plist, and to load it again run launchctl load -w ~/Library/LaunchAgents/local.backupLogicSessions.plist. In the second command here, the w flag Overrides the Disabled key and sets it to false or true for the load and unload subcommands respectively.
  • If you want to check that the daemon is running, run launchctl list | grep local.
  • Lastly, I found https://www.launchd.info/ to be a useful resource for this.

Step 5:

To do a test run, you can temporarily change StartCalendarInterval to be in 1 minute from now, or you can just call the bash script directly from the command line, in my case ./code/backupLogicSessions.sh if I’m in ~. You should see a notification pop up that looks like this:

And that’s it. There are some obvious downsides to this approach, namely:

  • you have to maintain the code, and if it breaks there’s no warranty 🤠; and
  • you have to keep a second copy of your Logic sessions folder on your computer, so it’s taking up twice as much room as it should

I’m planning on addressing the second point when I take another pass at this, but for now things are working, and I’ll be ok if my laptop spontaneously combusts. 🔥