-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathsync-apps-data
executable file
·49 lines (41 loc) · 1.02 KB
/
sync-apps-data
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
#!/bin/bash
#
# Synchronize apps data with a custom local folder that I back up frequently to an external drive.
#
# - Run the synchronization:
#
# `sync-apps-data`
#
# ---
# Author: Nick Plekhanov, https://nikkhan.com/
# License: MIT
# https://github.com/nicksp/dotfiles
set -eu
DEST="$HOME/Documents/MYDATA"
CYAN="$(tput setaf 6)"
UNDERLINE="$(tput sgr 0 1)"
RESET="$(tput sgr0)"
title() {
echo -e "${UNDERLINE}${CYAN}${1}${RESET}\n"
}
_bk() {
title "Backing up $1..."
dest_dir="$DEST/$2"
mkdir -p "$dest_dir"
# Remove any files/directories in the destination that are not in the source
# for item in "$dest_dir"/*; do
# if [ ! -e "$1/$(basename "$item")" ]; then
# rm -rf "$item"
# fi
# done
# Copy files/directories from the source to the destination
for item in "$1"/*; do
if [ -d "$item" ]; then
cp -R "$item" "$dest_dir"
else
cp "$item" "$dest_dir"
fi
done
}
# Bear notes/images synchronization
_bk "$HOME/Library/Group Containers/9K33E3U3T4.net.shinyfrog.bear/" "Bear"