-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_bck.py
executable file
·39 lines (33 loc) · 963 Bytes
/
extract_bck.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
#! /usr/bin/env python
import filecmp
import getpass
import logging
import os
import shutil
import socket
import sys
import time
from bck4sync import BckTarGroup
# Import configuration
import bck_config
from bck4sync import get_bcktargroups
bckdir_list = bck_config.bckdir_list
dest_dir = bck_config.dest_dir
work_dir = bck_config.work_dir
password = bck_config.password
# Main
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
logging.info('Start')
if not os.path.exists(work_dir):
os.makedirs(work_dir)
srce_dir = bckdir_list[0]
extract_dir = os.path.join(srce_dir, 'tmp')
if not os.path.exists(extract_dir):
os.makedirs(extract_dir)
bck_name = os.path.basename(os.path.normpath(srce_dir))
bck_list = get_bcktargroups(bck_name, dest_dir)
if bck_list:
last_bck = bck_list[-1]
my_backup = BckTarGroup(last_bck, \
srce_dir, dest_dir, work_dir, password)
my_backup.extract(extract_dir)