-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup-mac.sh
More file actions
executable file
·91 lines (64 loc) · 3.07 KB
/
backup-mac.sh
File metadata and controls
executable file
·91 lines (64 loc) · 3.07 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
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
############ VARIABLES / OPTIONS ############
CHECK_FOR_STALE_GITHUB="false"
COPY_TO_CRYPTOMATOR_VOLUME="false"
TARGET_IP="192.168.0.228"
TARGET_USER="dan"
GITHUB_SOURCE_DIR="/Users/dan/github"
GITHUB_TARGET_DIR="/Users/dan/github/"
ICLOUD_BACKUP_DIR="/Users/dan/Documents/backup/Foghorn/"
CRYPTOMATOR_DIR="/Volumes/encrypted"
LOCAL_ENCRYPTED_DIR="/Users/dan/Documents/encrypted"
HOME_FILES=(".zsh_history" ".viminfo" ".kube" ".oh-my-zsh" ".zshrc")
IMOVIE_SOURCE_DIR="/Users/dan/Movies/iMovie Library.imovielibrary"
IMOVIE_TARGET_DIR="/Users/dan/Movies/iMovie Library.imovielibrary"
########### Github repo status ############
if [[ $CHECK_FOR_STALE_GITHUB == "true" ]]; then
echo "############## Checking for stale Github repos ##############"
$SCRIPTS/git-status.sh
else
echo "############## Skipping stale Github check ##############"
fi
############## Github Backup ##############
# TODO: Skip .terraform files
echo "############## Backing up local Github to personal Macbook Pro ##############"
rsync -avtro --progress $GITHUB_SOURCE_DIR/* $TARGET_USER@$TARGET_IP:$GITHUB_TARGET_DIR
############## Home Dir contents ##############
echo "############## Capturing current home dir contents ##############"
ls -al $HOME > $ICLOUD_BACKUP_DIR/home-dir-contents.txt
############## Sensitive data backup ##############
# CryptoMator volume must be mounted
# CryptoMator volume is stored in ~/Documents/encrypted
if [[ $COPY_TO_CRYPTOMATOR_VOLUME == "true" ]]; then
echo "############## Copying encrypted files ##############"
rsync -avtro --progress $HOME/.ssh $CRYPTOMATOR_DIR/ssh
rsync -avtro --progress $HOME/.aws $CRYPTOMATOR_DIR/aws_creds
rsync -avtro --progress $HOME/.gnupg $CRYPTOMATOR_DIR/gnupg
# rsync -avtro --progress /Users/dan/Downloads/github-recovery-codes-dnlloyd-mcc.txt $CRYPTOMATOR_DIR/github-recovery-codes/
else
echo "############## Skipping encrypted files ##############"
fi
############## Home files backup ##############
echo "############## Backing up Home files to iCloud ##############"
for file in "${HOME_FILES[@]}"
do
rsync -avtro --progress ~/$file $ICLOUD_BACKUP_DIR/home-files/
done
############## Homebrew apps ##############
echo "############## Capturing Homebrew apps ##############"
brew list > $ICLOUD_BACKUP_DIR/homebrew-apps.txt
############## Mac installed apps ##############
echo "############## Mac installed apps ##############"
system_profiler SPApplicationsDataType > $ICLOUD_BACKUP_DIR/mac-installed-apps.txt
############## Pyenv versions ##############
echo "############## Pyenv versions ##############"
pyenv versions > $ICLOUD_BACKUP_DIR/pyenv-versions.txt
############## Pyenv versions ##############
echo "############## Crontab ##############"
crontab -l > $ICLOUD_BACKUP_DIR/crontab.txtls
############## iMovie projects ##############
echo "############## Backing up iMove projects to personal Macbook Pro ##############"
cd "/Users/dan/Movies/iMovie Library.imovielibrary"
for dir in $(ls -l | grep '^d' | awk '{print $9}' | egrep -v "^_|deleteme")
do
rsync -avtro --progress $dir $TARGET_USER@$TARGET_IP:"${IMOVIE_TARGET_DIR}"
done