You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See below. A dedicated template field that returns the filepath of the exported file relative to export directory would be helpful. Alternatively maybe a relative_to() option:
This might be limited by values permitted in the field name.
It is not currently possible to do this directly but there is a work-around (see below). Implementing something like this would take some re-architecture of the current code which requires inspection of the exported files to determine if one needs to be updated. OSXPhotos creates an export database (usually in the export folder) that could be stored locally and queried to see which files need to be updated so it's feasible but would require some code changes. I'm willing to open an issue for this (it would enable other backends like S3) but I'm very busy at the moment so this is likely very far down the road unless someone wants to submit a PR.
As a work around you could do an export to local disk and use the --post-command to export any newly exported or updated photo to the remote server using rsync. If you are using "Download originals to this Mac" in Photos and APFS on your Mac filesystem (the default for all Macs for sometime) and you are exporting the unmodified files from Photos (that is, you are not using the --exiftool or --convert-to-jpeg options) then OSXPhotos will use Copy-on-Write to copy the files out of the Photos library to the target directory. That means the exported files do not take up any additional space on the disk. I use this regularly to backup my own library so that the exported files can be browsed in Finder and will be backed up independently by Time Machine and Backblaze. Thus there's effectively no "cost" to doing this.
In this example, "exported" causes the command to be applied to any file that has been exported or updated. The OSXPhotos template system is used to specify the file path for rsync and the rsync --relative option is used to exclude the local export directory from the remote path. All OSXPhotos templates used in the command will be interpolated by OSXPhotos before being passed to the shell for execution. Here's a breakdown of the template {shell_quote,{export_dir}/./{filepath|chomp(35)}} :
{shell_quote,...} : use shell quoting for the following value so that spaces in directory names are properly quoted or escaped.
{export_dir} : the export directory passed to osxphotos export; this is the root path we'll want to exclude from the remote path.
/./ : used to indicate to rsync --relative which part of the path should be excluded
{filepath|chomp(35)} : {filepath} specifies the full path to the exported file. In this case, we want to chop off the beginning part so that only the part relative to the export directory is used. the |chomp(X) filter chops off X characters from the beginning of the passed value. You will need to specify this for your particular local export directory. Include one extra for the trailing slash. For example, if your export directory is Users/Pictures/user/photos_backup you would use |chomp(35) to remove the first 35 characters (34 for /Users/Pictures/user/photos_backup plus 1 for trailing /).
Commands run synchronously so the rsync will block further export until it completes. See also --post-command-error which allows you to control the behavior if there's an rsync error:
--post-command-error ACTION Specify either `continue` or `break` for ACTION to control behavior when a
post-command fails. If `continue`, osxphotos will log the error and continue
processing. If `break`, osxphotos will stop processing any additional
--post-command commands for the current photo but will continue with the
export. Without --post-command-error, osxphotos will abort the export if a
post-command encounters an error.
See below. A dedicated template field that returns the filepath of the exported file relative to export directory would be helpful. Alternatively maybe a
relative_to()
option:Something like:
{filepath.relative_to(/users/user/backup)}
This might be limited by values permitted in the field name.
It is not currently possible to do this directly but there is a work-around (see below). Implementing something like this would take some re-architecture of the current code which requires inspection of the exported files to determine if one needs to be updated. OSXPhotos creates an export database (usually in the export folder) that could be stored locally and queried to see which files need to be updated so it's feasible but would require some code changes. I'm willing to open an issue for this (it would enable other backends like S3) but I'm very busy at the moment so this is likely very far down the road unless someone wants to submit a PR.
As a work around you could do an export to local disk and use the
--post-command
to export any newly exported or updated photo to the remote server usingrsync
. If you are using "Download originals to this Mac" in Photos and APFS on your Mac filesystem (the default for all Macs for sometime) and you are exporting the unmodified files from Photos (that is, you are not using the--exiftool
or--convert-to-jpeg
options) then OSXPhotos will use Copy-on-Write to copy the files out of the Photos library to the target directory. That means the exported files do not take up any additional space on the disk. I use this regularly to backup my own library so that the exported files can be browsed in Finder and will be backed up independently by Time Machine and Backblaze. Thus there's effectively no "cost" to doing this.--post-command exported "rsync -avz --relative {shell_quote,{export_dir}/./{filepath|chomp(35)}} [email protected]:/home/photos_backup"
In this example, "exported" causes the command to be applied to any file that has been exported or updated. The OSXPhotos template system is used to specify the file path for rsync and the rsync
--relative
option is used to exclude the local export directory from the remote path. All OSXPhotos templates used in the command will be interpolated by OSXPhotos before being passed to the shell for execution. Here's a breakdown of the template{shell_quote,{export_dir}/./{filepath|chomp(35)}}
:{shell_quote,...}
: use shell quoting for the following value so that spaces in directory names are properly quoted or escaped.{export_dir}
: the export directory passed toosxphotos export
; this is the root path we'll want to exclude from the remote path././
: used to indicate torsync --relative
which part of the path should be excluded{filepath|chomp(35)}
:{filepath}
specifies the full path to the exported file. In this case, we want to chop off the beginning part so that only the part relative to the export directory is used. the|chomp(X)
filter chops offX
characters from the beginning of the passed value. You will need to specify this for your particular local export directory. Include one extra for the trailing slash. For example, if your export directory isUsers/Pictures/user/photos_backup
you would use|chomp(35)
to remove the first 35 characters (34 for/Users/Pictures/user/photos_backup
plus 1 for trailing/
).Commands run synchronously so the
rsync
will block further export until it completes. See also--post-command-error
which allows you to control the behavior if there's an rsync error:Originally posted by @RhetTbull in #1711 (comment)
The text was updated successfully, but these errors were encountered: