Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
Preliminary fix for issue #163
Browse files Browse the repository at this point in the history
  • Loading branch information
ShahriyarR committed Nov 7, 2017
1 parent 1d613d1 commit 57183b7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion autoxtrabackup.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def validate_file(file):
default='/etc/bck.conf',
show_default=True,
help="Read options from the given file")
@click.option('--tag',
help="Pass the tag string for each backup")
@click.option('-v', '--verbose', is_flag=True,
help="Be verbose (print to console)")
@click.option('-lf',
Expand Down Expand Up @@ -156,7 +158,7 @@ def validate_file(file):
is_eager=False,
help="Print help message and exit.")
@click.pass_context
def all_procedure(ctx, prepare, backup, partial, verbose, log_file, log, defaults_file, dry_run, test_mode):
def all_procedure(ctx, prepare, backup, partial, tag, verbose, log_file, log, defaults_file, dry_run, test_mode):
logger.setLevel(log)
formatter = logging.Formatter(fmt='%(asctime)s %(levelname)-8s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
Expand Down
9 changes: 8 additions & 1 deletion master_backup_script/backuper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@

class Backup(GeneralClass):

def __init__(self, config='/etc/bck.conf', dry_run=0):
def __init__(self, config='/etc/bck.conf', dry_run=0, tag=None):
self.conf = config
self.dry = dry_run
self.tag = tag
# Call GeneralClass for storing configuration options
super().__init__(self.conf)

@staticmethod
def add_tag(backup_dir, backup_name, type, tag_string):
with open('{}/backup_tags.txt'.format(backup_dir), 'w') as bcktags:
bcktags.write("{0}\t{1}\t{2}\n".format(backup_name, type, tag_string))
pass

@staticmethod
def sorted_ls(path):
'''
Expand Down
1 change: 1 addition & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from prepare_env_test_mode.run_benchmark import RunBenchmark
from prepare_env_test_mode.config_generator import ConfigGenerator
from prepare_env_test_mode.runner_test_mode import RunnerTestMode
from master_backup_script.backuper import Backup

clb_obj = CloneBuildStartServer()

Expand Down
14 changes: 14 additions & 0 deletions test/test_backup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# PyTest file for testing Backup class
from master_backup_script.backuper import Backup
from general_conf.generalops import GeneralClass

class TestBackup:

def test_add_tag(self):
# Method for checking the add_tag() static method. All parameters are hard coded.
gen_obj = GeneralClass()
for conf_files in gen_obj.xb_configs.split():
if '2_3' in conf_files and '5_6' in conf_files:
obj = Backup(config='{}/{}'.format(gen_obj.testpath, conf_files), dry_run=0, tag="My first full backup")
backup_name = obj.recent_full_backup_file()
obj.add_tag(backup_dir=obj.backupdir, backup_name=backup_name, type=obj.tag)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from general_conf.generalops import GeneralClass
from prepare_env_test_mode.prepare_backup import WrapperForPrepareTest

# Part of TEST MODE

class TestPrepareBackup:
# class for prepare_env_test_mode.prepare_backup.py
Expand Down
2 changes: 2 additions & 0 deletions test/test_take_backup.py → test/test_test_take_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from prepare_env_test_mode.take_backup import WrapperForBackupTest
from general_conf.generalops import GeneralClass

# Part of TEST MODE

class TestTakeBackup:
# Test class for take_backup.py

Expand Down

0 comments on commit 57183b7

Please sign in to comment.