-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbackup.py
81 lines (75 loc) · 1.98 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import os
import subprocess
from pathlib import Path
import shutil
home = Path("~").expanduser()
pwd = Path(__file__).parent
# remove backup folder if exists
if os.path.exists(pwd / "backup"):
shutil.rmtree(pwd / "backup")
# custom scripts
scripts = [
'/usr/bin/color_show',
home / "remove_newline_when_select.sh"
]
# related to X11
X = [
# home / ".Xresources",
home / ".xprofile",
home / ".xinitrc",
home / ".Xclients",
]
SHELLS = [
home / ".zshrc", # zsh
# bash
home / ".bashrc",
home / ".profile", # not loaded when bash_profile present
home / ".bash_profile",
]
software = [
home / ".ssh/config", # ssh key and config
home / ".gdbinit", # gdb dashbaord
home / ".gitconfig",
home / ".config/i3/",
home / ".config/i3status/",
home / ".config/kitty/",
home / ".config/ranger/",
# vs code
home / ".config/Code/User/settings.json",
home / ".config/Code/User/keybindings.json",
home / ".config/rofi",
home / ".local/share/rofi", # themes
home / ".emacs.d/init.el",
home / ".config/autokey/data/",
home / ".config/zathura/",
home / ".config/cmus/",
home / ".config/sioyek",
home / ".config/neofetch",
home / ".config/doublecmd",
home / ".config/.ripgreprc",
# Ipython
home / ".ipython/profile_default/ipython_config.py",
home / ".jupyter/jupyter_lab_config.py",
# jetbrains
home / ".ideavimrc",
# conda
home / ".condarc",
# wallpaper
home / "Pictures"
]
directory = [scripts, X, SHELLS, software]
for d in directory:
for f in d:
if os.path.exists(f):
src = str(f).replace(str(home), "home/USERNAME")
if src.startswith("/"):
src = src[1:]
dst = pwd / "backup" / src
Path(dst).parent.mkdir(parents=True, exist_ok=True)
cmd = [
"cp", "-r", f, dst
]
print(f, cmd)
subprocess.run(
cmd,
)