Skip to content

Backup Mac Photos Library with Rsync over SSH

In the last couple of days I was looking for a cheap and secure way to backup my entire Mac Photos library. Apple limits its iCloud storage to 5GB which obviously isn’t enough to backup your entire holiday photos that you collected over the past few years. I considered the option to simply upgrade my iCloud plan to 200GB and pay $3.99 monthly to get it taken care of. I also considered using Amazons new Cloud Drive as it offers unlimited free storage of photos for just $11.99 a year. It’s pretty tempting to simply use one of those services but obviously this comes with a few strings attached.

For example have a look at Amazons terms and conditions:

3.3 Our Use of Your Files to Provide the Service. We may use, access, and retain Your Files in order to provide the Service to you and enforce the terms of the Agreement, and you give us all permissions we need to do so. These permissions include, for example, the rights to copy Your Files for backup purposes, modify Your Files to enable access in different formats, use information about Your Files to organize them on your behalf, and access Your Files to provide technical support. Amazon respects your privacy and Your Files are subject to the Amazon.com Privacy Notice located at www.amazon.com/privacy.

Source: http://www.amazon.com/gp/help/customer/display.html/?nodeId=201376540

This pretty much means they can do what ever they want with your photos. I was trying to avoid this and also looked into Amazon Glacier as it’s considered to be the perfect solution for a fast and cheap backup. As I didn’t want to pay much extra, I started liking the idea of backing my files up to my own Server as I still have a lot of free storage that I don’t use.

I decided to simply use Rsync and a cronjob on my Mac to backup my entire Photos (formerly iPhoto library).

Step 1: Create remote folder

Pick a folder on your remote server to backup your photos to. I decided to simply go with “backup” in my home directory.

kgoedecke@my-vps:~$ mkdir backup

Step 2: Run initial backup

For this HowTo I’m assuming you have access to your Server configured with an SSH key so it doesn’t prompt you for the password every time you access it.

Make an initial backup of your Photos library running the Rsync command for the first time.

Kevins-MBP:~ kevin$  rsync -Phca --bwlimit=1000 --delete --stats --include="/Photos Library.photoslibrary/" --include="/Photos Library.photoslibrary/***" --exclude="*" -e "ssh" "/Users/kevin/Pictures/" kevin@kevingoedecke.com:~/backup/

Explanation of the params:

  • -P Shows the progress during the backup process
  • -h Displays everything in a human-readable way, for example MB instead of bytes
  • -c Creates a checksum to compare files
  • -a Copies and keeps subdirectories, symbolic links, rights, group rights and timestamps
  • --bwlimit=5000 Limits the bandwidth to 1MB/s to not eat up my entire upload during the backup process.
  • --delete If a file in my local Photos library was deleted, the file will also be deleted on the remote backup to save storage
  • --stats Shows a report after sync completion
  • -e Use ssh as the remote interface
  • --include="/Photos Library.photoslibrary/" We need to specify that we only want to sync “Photos Library.photoslibrary”  within the “Pictures” folder. To do this, we need to exclude everything except the “Photos Library.photoslibray” folder.
  • --include="/Photos Library.photoslibrary/***" Sync not only the folder, but also its content.
  • --exclude="*" Don’t sync anything else, only what has been specified with --include.

Step 3: Setup a cronjob

In order to backup your files on a regular basis we will setup a cronjob on your Mac. This will make sure that your files are being backed up every X days. I decided to backup the photos once a week each Sunday.

First create a bash script for our Rsync command:

Kevins-MBP:~ kevin$ cd ~
Kevins-MBP:~ kevin$ nano backup_photos.sh

Insert your Rsync command:

#!/bin/sh
rsync -Phca --bwlimit=1000 --delete --stats --include="/Photos Library.photoslibrary/" --include="/Photos Library.photoslibrary/***" --exclude="*" -e "ssh" "/Users/kevin/Pictures/" kevin@kevingoedecke.com:~/backup/

Afterwards make the script executable.

Kevins-MBP:~ kevin$ chmod ug+x backup_photos.sh

Open the terminal and run the following

Kevins-MBP:~ kevin$ crontab -e

This will open VIM where you can create the actual cronjob. Press the “i” key on your keyboard to enter the “insert” mode of VIM and insert the following command:

* * * * 7 ~/backup_photos.sh

Afterwards hit “ESC” and type “:wq” to save and close VIM.

That’s it. Now you’re all set and your photos will be backup automatically every Sunday.

Published inUncategorized

Comments are closed.