-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.py
63 lines (51 loc) · 1.15 KB
/
backup.py
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
from shutil import copy
from os.path import expanduser, dirname, abspath, isdir, isfile
from os import mkdir
from distutils.dir_util import copy_tree
files = [
".zshrc",
".vimrc",
".profile",
".gitignore",
".gitconfig",
".config/lock.py",
"bin/=",
"bin/battery.sh",
"bin/emoj",
"bin/youtube.sh",
".emacs.d/init.el"
]
folders = [
".config/i3",
".config/i3blocks",
".config/i3status",
".config/rofi"
]
for file in files:
src_path = "/".join([
expanduser("~"),
file
])
dest_path = "/".join([
dirname(abspath(__file__)),
"files",
file
])
dest_parts = dest_path.split("/")[1:-1]
current_path = ""
for part in dest_parts:
current_path = "/".join([current_path, part])
if not isdir(current_path) and not isfile(current_path):
mkdir(current_path)
copy(src_path, dest_path)
for folder in folders:
src_path = "/".join([
expanduser("~"),
folder
])
dest_path = "/".join([
dirname(abspath(__file__)),
"files",
folder
])
copy_tree(src_path, dest_path)