-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorb
executable file
·110 lines (95 loc) · 2.78 KB
/
orb
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
# OSX Rsync Backup (ORB)
#
# ORB is a RSync script to backup your entire osx disk/partition.
# You can also boot from your backup disk/partition (Very useful for test or restore functions).
#
# Created by: Rafael Biriba - [email protected]
# More info: https://github.com/rafaelbiriba/ORB-osx-rsync-backup
# USAGE: (With inline parameters)
# $ sudo ./orb /Volumes/OSX-Source/ /Volumes/OSX-Destination/
# USAGE: (With local environment variables)
# $ export ORB_SOURCE='/Volumes/OSX-Source/'
# $ export ORB_DESTINATION='/Volumes/OSX-Destination/'
# $ sudo -E env ./orb
SCRIPT_USAGE="\n
USAGE: (With inline parameters)
\n
$ sudo ./orb /Volumes/OSX-Source/ /Volumes/OSX-Destination/
\n\n
USAGE: (With local environment variables)
\n
$ export ORB_SOURCE='/Volumes/OSX-Source/'
\n
$ export ORB_DESTINATION='/Volumes/OSX-Destination/'
\n
$ sudo -E env ./orb
\n\n"
if [ -n "$1" ] && [ -n "$2" ]; then
SOURCE=${1%/}
DESTINATION=${2%/}
fi
if [ -n "$ORB_SOURCE" ] && [ -n "$ORB_DESTINATION" ]; then
SOURCE=${ORB_SOURCE%/}
DESTINATION=${ORB_DESTINATION%/}
fi
if ! [ -n "$SOURCE" ] && ! [ -n "$DESTINATION" ]; then
echo -e $SCRIPT_USAGE
exit;
fi
echo -e "\n"
echo -e "Starting ORB backup script...\n"
# Make sure only root can run the script
if [[ $EUID -ne 0 ]]; then
echo -e "Aborting the sync process: This script must be run as root\n"
exit;
fi
if [ ! -r "$SOURCE" ]; then
echo -e "Aborting the sync process: Source '$SOURCE/' not readable\n"
exit;
fi
if [ ! -w "$DESTINATION" ]; then
echo -e "Aborting the sync process: Destination '$DESTINATION/' not writeable\n"
exit;
fi
echo -e "Check the selected folders:"
echo -e "Source folder: $SOURCE/"
echo -e "Destinantion folder: $DESTINATION/"
echo -e "Waiting 5 seconds before continue. [Control+C] to cancel the execution if something is wrong..."
sleep 5
echo -e "Executing..."
rsync --acls \
--archive \
--delete \
--delete-excluded \
--hard-links \
--one-file-system \
--sparse \
--verbose \
--xattrs \
--times \
--crtimes \
--human-readable \
--progress \
--perms \
--executability \
--owner \
--group \
--exclude '.Spotlight-*' \
--exclude '.Trashes' \
--exclude '/afs/*' \
--exclude '/automount/*' \
--exclude '/cores/*' \
--exclude '/dev/*' \
--exclude '/Network/*' \
--exclude '/private/tmp/*' \
--exclude '/private/var/run/*' \
--exclude '/private/var/spool/postfix/*' \
--exclude '/private/var/vm/*' \
--exclude '/Previous Systems.localized' \
--exclude '/tmp/*' \
--exclude '/Volumes/*' \
--exclude '*/.Trash' \
"$SOURCE"/ "$DESTINATION"/
bless --folder "$DESTINATION"/System/Library/CoreServices
exit 0