It does not need any fix or workaround - it just needs to do the backup setup job right.
The root cause is very simple here - backing up live data. And on macOS Library/Application Support
is probably the worst directory to attempt to do it. If you are backing up your cat pictures dir from Documents
then only risk is data corruption/inconsistency but Library
is busy with system and apps doing there all sort of stuff constantly. And unfortunately some locked files can even cause all snapshot to fail.
Here good summary why it is bad idea to backup live data:
And there are not really excuses on macOS beyond being lazy for not doing it right.
File system snapshots are supported by APFS and kopia can make use of them in very easy way.
Here for reference my two scripts I use as kopia snapshot actions:
BEFORE:
#!/bin/bash
# https://kopia.io/docs/advanced/actions/#action-environment
# When kopia invokes Before actions,
# it passes the following parameter (more in docs):
# Variable Description
# KOPIA_SNAPSHOT_ID Random 64-bit number
# KOPIA_SOURCE_PATH Path being snapshotted
# The action command can modify the contents source directory in place
# or it can request other directory be snapshotted instead by printing a line to standard output:
# KOPIA_SNAPSHOT_PATH=<new-directory>
# Exit on error
set -o errexit
VOLUME_PATH="/System/Volumes/Data"
SNAP_DATE=$(/usr/bin/tmutil snapshot "$VOLUME_PATH" | /usr/bin/tail -n1 | /usr/bin/sed s/'Created local snapshot with date: '//)
LOCAL_MOUNTPOINT=/tmp/kopia_snapshot_"$KOPIA_SNAPSHOT_ID"
mkdir "$LOCAL_MOUNTPOINT" || true
umount "$LOCAL_MOUNTPOINT" || true
# for this to work add "Full Disk Access" for "Kopia UI"
/sbin/mount -t apfs -o nobrowse,-r,-s="com.apple.TimeMachine.${SNAP_DATE}.local" "$VOLUME_PATH" "$LOCAL_MOUNTPOINT"
echo KOPIA_SNAPSHOT_PATH="$LOCAL_MOUNTPOINT"/"$KOPIA_SOURCE_PATH"
AFTER:
#!/bin/bash
# https://kopia.io/docs/advanced/actions/#action-environment
# When kopia invokes After actions,
# it passes the following parameter (more in docs):
# Variable Description
# KOPIA_SNAPSHOT_ID Random 64-bit number
# Exit on error
set -o errexit
LOCAL_MOUNTPOINT=/tmp/kopia_snapshot_"$KOPIA_SNAPSHOT_ID"
umount "$LOCAL_MOUNTPOINT" || true
rm -rf "$LOCAL_MOUNTPOINT" || true
configured in kopia UI:
and do not forget to enable actions - they are off by default. You can not do this via GUI. As per docs:
When using KopiaUI, actions can be enabled globally by editing your repository.config (it is located in the
Config File
location in KopiaUI underRepository
) and change"enableActions": false
to"enableActions": true
. Save the file and restart KopiaUI.
Do above when kopia is not running.