-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-backup.sh
executable file
·50 lines (32 loc) · 1.1 KB
/
config-backup.sh
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
#!/usr/bin/env bash
# Backup Obsidian Configuration
# - Makes a copy of your Obsidian configuration to the config directory here
# Setup the message colour characters
blue="\033[0;34m"
green="\033[0;32m"
yellow="\033[0;33m"
red="\033[0;31m"
end="\033[0m"
# Location of the Obsidian vault configuration directory
CONFIG_DIR=$HOME"/Notes/.obsidian"
# Location of the config directory here
UPDATE_DIR="./config"
# Ask for confirmation from the user before continuing
read -p "$(echo -e $blue"This script will update your config files here from your Obsidian configuration directory at "$CONFIG_DIR". Continue this process? (y/n) "$end)" ANSWER
if [ "$ANSWER" != "y" ]; then
echo -e "${red}User cancelled, restore aborted.${end}"
exit 1
fi
# Backup current config files
echo -e "${yellow}Updating current config from files in $CONFIG_DIR${end}"
mkdir -p $CONFIG_DIR
rm -rf $UPDATE_DIR
mkdir -p $UPDATE_DIR
cp -r $CONFIG_DIR/* $UPDATE_DIR
# Commit config updates
echo -e "${yellow}Committing and pushing changes${end}"
git add config/*
git commit -m "Update config"
git push
# Done
echo -e "${green}Done.${end}"