-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbackup
executable file
·44 lines (37 loc) · 1.1 KB
/
backup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
if (( $# < 2)); then
echo "Usage: $0 status|exclude|include" path
exit 1
fi
action=$1
target_path=$2
if [[ ! -e $target_path ]]; then
echo "File not found: $target_path"
exit 1
fi
xattr -pl com.apple.metadata:com_apple_backup_excludeItem "$target_path" >/dev/null 2>&1 && is_currently_excluded=1
case $action in
status)
if [[ $is_currently_excluded ]]; then
echo "Item is excluded from backup"
else
echo "Item is not excluded from backup"
fi
;;
exclude)
if [[ $is_currently_excluded ]]; then
echo "Item is already excluded from backup"
else
xattr -w com.apple.metadata:com_apple_backup_excludeItem com.apple.backupd "$target_path"
echo "Item is now excluded from backup"
fi
;;
include)
if [[ $is_currently_excluded ]]; then
echo "Item is now included in backup"
xattr -d com.apple.metadata:com_apple_backup_excludeItem "$target_path"
else
echo "Item is already included in backup"
fi
;;
esac