IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40894


Ignore:
Timestamp:
Sep 24, 2019, 10:52:39 AM (7 years ago)
Author:
fairlamb
Message:

enabled mysqldump for atlassian backups

Location:
branches/ipp-132_automate_jira_conf_backups/backups
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/ipp-132_automate_jira_conf_backups/backups/atlassian_backups.config

    r40893 r40894  
    88conf_attachments_path = /var/atlassian/application-data/confluence/attachments
    99mysqldump_password = not_a_real_password
    10 verbose = True
     10verbose = False
  • branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications.py

    r40893 r40894  
    9999        self.verbose               = config.getboolean('atlassian_backups', 'verbose')
    100100
     101        self.mysqldump_password    = _get_str_key_from_section(config, section, 'mysqldump_password')
     102
    101103    def target_backup_paths_ok(self) -> bool:
    102104        copy_paths = [ self.host_backup_path
     
    150152        tar_return = self._tar_attachments()
    151153
     154        # mysqldump
     155        mysqldump_return = self.make_mysql_dump(self.mysqldump_password)
     156
    152157        # If successful: move tmp to old
    153         if jira_return == 0 and conf_return == 0 and tar_return == 0:
     158        if jira_return == 0 and conf_return == 0 and tar_return == 0 and mysqldump_return == 0:
    154159            _move_dir_contents_to_dir(tmp_paths, old_paths, self.verbose)
    155160        else:
     
    252257        # do this as the dumper user
    253258
     259        print(dump_password)
     260
    254261        latest_paths = self.target_paths("latest")
    255262        if not self.target_backup_paths_ok():
     
    270277                         , '--databases', 'jiradb', 'confluencedb'
    271278                         ]
     279        print(mysqldump_args)
    272280        with open(dump_filepath, "w+") as df:
    273281            mysqldump_process = subprocess.Popen(mysqldump_args, stdout=df, stderr=subprocess.PIPE)
     
    278286        if stde is not None:
    279287            decoded_stderr = stde.decode()
     288            print(decoded_stderr)
     289            print(decoded_stderr.casefold().find('error'.casefold()))
    280290            if decoded_stderr.casefold().find('error'.casefold()) > -1:
    281291                raise sub_utils.SubprocessError()
  • branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications_test.py

    r40893 r40894  
    2525        'conf_backup_path'      : os.path.join(tmpdir, 'conf_backup_path'),
    2626        'jira_attachments_path' : os.path.join(tmpdir, 'jira_attachments_path'),
    27         'conf_attachments_path' : os.path.join(tmpdir, 'conf_attachments_path')
     27        'conf_attachments_path' : os.path.join(tmpdir, 'conf_attachments_path'),
     28        'mysqldump_password'    : 'not_a_real_password'
    2829    }
    2930
     
    4243        assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data"
    4344        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
     45        assert ab.mysqldump_password    == "not_a_real_password"
    4446        assert ab.verbose is True
    4547
     
    5456        assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data"
    5557        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
     58        assert ab.mysqldump_password    == "not_a_real_password"
    5659
    5760    def test_default_arguments(self):
     
    6568        assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data"
    6669        assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments"
     70        assert ab.mysqldump_password    == "not_a_real_password"
    6771
    6872    def test_providing_config_directly(self):
     
    7680        config.set('atlassian_backups', 'jira_attachments_path', 'custom_config6')
    7781        config.set('atlassian_backups', 'conf_attachments_path', 'custom_config7')
     82        config.set('atlassian_backups', 'mysqldump_password',    'custom_config8')
    7883        config.set('atlassian_backups', 'verbose', 'False')
    7984
     
    8792        assert ab.jira_attachments_path == 'custom_config6'
    8893        assert ab.conf_attachments_path == 'custom_config7'
     94        assert ab.mysqldump_password    == 'custom_config8'
    8995        assert ab.verbose is False
    9096
     
    386392    """ The mySQL dump tests require the machine on which they are
    387393running to have a mysql database running with a user called
    388 'dumper' and the password listed below.
    389 
     394'dumper' and a password set to 'not_a_real_password'.
     395
     396In production, a proper password should be set on the server and in the config
     397file.
     398
     399To change the password:
    390400UPDATE mysql.user SET authentication_string = PASSWORD('NEW_USER_PASSWORD')WHERE User = 'user-name' AND Host = 'localhost';FLUSH PRIVILEGES;
    391 
    392 Note that the actual password used for the backups is not included here,
    393 or in the main backup code for security.
    394401"""
    395402
Note: See TracChangeset for help on using the changeset viewer.