-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbak
More file actions
executable file
·49 lines (41 loc) · 1.29 KB
/
bak
File metadata and controls
executable file
·49 lines (41 loc) · 1.29 KB
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
45
46
47
48
49
#!/usr/bin/env bash
# Names of backup disks
DISK=( MacOSX2 Seagate3TB ZwartUSB )
# Check which backup disk is mounted
DEST=
for VOL in "${DISK[@]}"; do
FOUND=$(mount | grep -c " on /Volumes/$VOL (")
[ $FOUND -eq 1 ] && { DEST="$VOL"; break; }
done
[ -z "$DEST" ] && { echo 'No backup disk found.' 1>&2; exit 1; }
echo "Using backup disk: $DEST"
# Double check if directory actually exists
DEST="/Volumes/$DEST"
[ ! -d "$DEST" ] && { echo "Directory not found: $DEST" 1>&2; exit 2; }
# Test if I am root
U=$(whoami)
if [[ "x${U}x" != "xrootx" ]]; then
N=$(basename "$0")
echo "This script needs to be run as root. Use: sudo $N" 1>&2
exit 3
fi
# Copy application directory to backup disk
echo
echo " Applications:"
echo
rsync -au --exclude='.DS_Store' --info=progress2,stats3 /Applications "$DEST"
# Copy System Library to backup disk
echo
echo " Library:"
echo
rsync -au --exclude='Caches' --exclude='.DS_Store' --info=progress2,stats3 /Library "$DEST"
# Copy some root directories to backup disk
echo
echo " Miscellaneous root dirs:"
echo
rsync -au --exclude='.DS_Store' --info=progress2,stats3 /bin /sbin /private /usr /opt "$DEST"
# Copy contents of Users directory to backup disk
echo
echo " Users:"
echo
rsync -au --exclude='Caches' --exclude='.DS_Store' --info=progress2,stats3 /Users "$DEST"