---
title: MacOS Photos Backup
date: 2017-12-26T11:45:14+00:00
modified: 2017-12-26T11:45:14+00:00
image:: https://kaspars.net/wp-content/uploads/2017/12/macos-photos-archive-month-year-directory.png
permalink: https://kaspars.net/blog/macos-photos-backup
post_type: post
author:
  name: Kaspars
  avatar: https://reverse.kaspars.net/gravatar/avatar/92bfcd3a8c3a21a033a6484d32c25a40b113ec6891f674336081513d5c98ef76?s=96&d=mm&r=g
post_tag:
  - How to
  - Tool
category:
  - Meta
---

# MacOS Photos Backup

All photos, videos and the associated meta data for the MacOS Photos library is stored in the `Photos Library` directory under `Pictures` in your home directory. However, the original files are placed in randomly named directories that are impossible to navigate outside of the Photos app.

For a simple backup I wanted to create a directory of all original photos and videos organised by year and month. So I wrote [a PHP script](https://github.com/kasparsd/photos-sync) which does the following:

1. parses the Photos database file to find the location of all originals,
2. creates symbolic links to the originals organized in directories named by year and month of the original `YYYY-MM` and prefixes all filenames with an md5 hash of the file.

[![Archive of MacOS Photos Organized by Date](https://kaspars.net/wp-content/uploads/2017/12/macos-photos-archive-month-year-directory.png?strip=all&quality=90&resize=800,467)](https://github.com/kasparsd/photos-sync)

We end up with a flat directory structure that can be easily synced to any remote location using `rsync` which takes care of resolving the symbolic links:

```
$ rsync --copy-links --archive links/ /path/to/destination
```

## Interesting Applications

Now you’re able to do things like:

- merge multiple libraries,
- find items that are not present in one of the libraries.