https://github.com/kasparsd/photos-sync
Sync OS X Photos to Anywhere (NAS, Dropbox, Amazon S3 or Glacier, Backblaze B2)
https://github.com/kasparsd/photos-sync
macos photos rsync symlink
Last synced: 6 months ago
JSON representation
Sync OS X Photos to Anywhere (NAS, Dropbox, Amazon S3 or Glacier, Backblaze B2)
- Host: GitHub
- URL: https://github.com/kasparsd/photos-sync
- Owner: kasparsd
- Created: 2015-12-26T11:09:18.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-12-26T13:44:49.000Z (almost 8 years ago)
- Last Synced: 2025-04-30T17:02:16.589Z (6 months ago)
- Topics: macos, photos, rsync, symlink
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 35
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sync and Backup OS X Photos to Any Location

A script that creates a folder with symbolic links (symlinks) to all of the OS X Photos originals which can be _rsynced_ to any location. I use it to share all my photos with the rest of the family using a shared WD EX2 drive. This allows me to avoid adding everything to the Family shared album on iCloud Photos.
$ git clone https://github.com/kasparsd/photos-sync.git
$ php photos-sync/symlink-photos.phpIt reads the OS X Photos database (SQLite) at `~/Pictures/Photos Library.photoslibrary/database/Library.apdb` (a copy of it) and creates symlinks to all original photos and videos in the `photos-sync/links` folder organized by month and filenames prepended with an `md5` hash of the file path to avoid collisions.
It can then be sent to any location using rsync or any other tool of preference. Here is a sample bash script which could be added to cron:
#!/bin/bash
# Ensure that we're always relative to the current directory
cd "$(dirname "$0")"# Symlink photos and rsync to the network share
php symlink-photos.php# Mount the network share
mount_afp afp://western.local/Public /Volumes/Public# Resolve and synchronize symlinks to the network share
rsync -avL links/ /Volumes/Public/Photoswhere `-L` ensures that rsync resolves the symlinks.
Run it every hour via cron `crontab -e`:
30 * * * * pgrep -f sync.sh || /path/to/sync.sh
where `pgrep -f sync.sh` will ensure that no other sync process is in progress.