-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.sh
executable file
·66 lines (52 loc) · 1.16 KB
/
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
BACKUP_DIR=~/migration
echo 'Do you want a backup of your old files?'
read -p 'Continue? ' -n 1 -r
echo #
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
echo 'Creating backup'
echo #
mkdir -p ${BACKUP_DIR}/home
# brew
if hash brew 2>/dev/null; then
brew leaves > ${BACKUP_DIR}/home/brew-list.txt
fi
# npm
if hash npm 2>/dev/null; then
npm list -g --depth=0 > ${BACKUP_DIR}/home/npm-g-list.txt
fi
# configs
declare -a BACKUP_FILES=(
'.aliases'
'.bash_profile'
'.bash_prompt'
'.bashrc'
'.exports'
'.extra'
'.functions'
'.zshrc'
'.gitattributes'
'.gitconfig'
'.gitconfig.local'
'.gitignore'
)
for file in "${BACKUP_FILES[@]}"; do
cp ~/${file} ${BACKUP_DIR}/home
done
# ssh / pgp keys
cp -R ~/.ssh ${BACKUP_DIR}/home
cp -R ~/.gnupg ${BACKUP_DIR}/home
# sublime text settings
mkdir -p ${BACKUP_DIR}/subl
cp -R ~/Library/Application\ Support/Sublime\ Text\ 3/Packages ${BACKUP_DIR}/subl
# wifi
mkdir -p ${BACKUP_DIR}/osx
cp /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist ${BACKUP_DIR}/osx
# bin
mkdir -p ${BACKUP_DIR}/bin
cp -R ~/bin ${BACKUP_DIR}/bin
echo 'Backup finished'
echo #