-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup
executable file
·47 lines (37 loc) · 1.09 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
45
46
47
#!/bin/bash -e
echo_info() {
gum style \
--foreground 212 --border-foreground 212 --border double \
--align left --width 50 --margin "1 0" --padding "0 1" \
"💁 $1"
}
echo_colored() { echo -e "${2}$1\033[0m"; }
fail() {
echo_colored "$1" "\033[1;31m"
exit 1
}
backup-file-or-dir() {
local _src="$1"
if [[ -f "$_src" ]]; then
echo "Backing up $_src"
cp "$_src" "$_backup_dir/"
elif [[ -d "$_src" ]]; then
echo "Backing up $_src"
cp -r "$_src" "$_backup_dir/"
else
echo "Skipping $_src, it doesn't exist"
fi
}
main() {
echo_info "Backing up interesting files to iCloud..."
backup-file-or-dir "$HOME/.wyh_history"
backup-file-or-dir "$HOME/.invoicer"
gum style "🚀 Backup complete" \
--foreground 35 --bold \
--margin "1 0" --padding "0 1" \
--border "rounded" --border-foreground 35 \
--width 50 --align center
}
_backup_dir="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Backups/dotfiles/$(date +'%Y-%m-%d %H:%M:%S')"
mkdir -p "$_backup_dir"
main "$@"