コード例 #1
0
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)

コード例 #2
0
# Output
print "Nb elements: " + str(len(bck_submembers6))
if result:
    print 'Test 6: OK\n\n'
else:
    print 'Test 6: KO'
    sys.exit(3)   

time.sleep(1)
# Test 7
print "List existing backup"
# Preparation
print '-'*5 + ' Test 7 ' + '-'*5
result = True
# Test
bck_list = get_bcktargroups(prefix, dest_dir)
# Output
print bck_list
last_bck = bck_list[-1]
print last_bck
if result:
    print 'Test 7: OK\n\n'
else:
    print 'Test 7: KO'
    sys.exit(7)

# Test 8
print "Delete oldest backups"
print '-'*5 + ' Test 8 ' + '-'*5
# Preparation
result = True
コード例 #3
0
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)

for bckdir in bckdir_list:
    bckdir_base = os.path.basename(os.path.normpath(bckdir))
    bck_list = get_bcktargroups(bckdir_base, dest_dir)
    if bck_list:
        last_bck = bck_list[-1]
        my_backup = BckTarGroup(last_bck, \
                bckdir, dest_dir, work_dir, password)
        my_backup.update()
    else:
        logging.debug('Backup ' + bckdir_base)
        my_backup = BckTarGroup(bckdir_base, \
                bckdir, dest_dir, work_dir, password)
        my_backup.create()
コード例 #4
0
ファイル: extract_bck.py プロジェクト: RaoulDebaze/sibsync
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)