forked from clintmod/macprefs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh_files.py
More file actions
28 lines (24 loc) · 761 Bytes
/
ssh_files.py
File metadata and controls
28 lines (24 loc) · 761 Bytes
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
from os.path import exists
import logging as log
from config import get_ssh_backup_dir, get_ssh_user_dir, get_user, ensure_exists
from utils import copy_dir, ensure_dir_owned_by_user
def backup():
source = get_ssh_user_dir()
if not exists(source):
log.info('No .ssh dir found... skipping.')
return
log.info('Backing up .ssh dir...')
dest = get_ssh_backup_dir()
ensure_exists(dest)
copy_dir(source, dest)
def restore():
source = get_ssh_backup_dir()
if not exists(source):
log.info('No .ssh dir found... skipping.')
return
log.info('Restoring .ssh dir...')
dest = get_ssh_user_dir()
copy_dir(
source, dest, with_sudo=True
)
ensure_dir_owned_by_user(dest, get_user())