Changeset 40894
- Timestamp:
- Sep 24, 2019, 10:52:39 AM (7 years ago)
- Location:
- branches/ipp-132_automate_jira_conf_backups/backups
- Files:
-
- 3 edited
-
atlassian_backups.config (modified) (1 diff)
-
backup_atlassian_applications.py (modified) (5 diffs)
-
backup_atlassian_applications_test.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ipp-132_automate_jira_conf_backups/backups/atlassian_backups.config
r40893 r40894 8 8 conf_attachments_path = /var/atlassian/application-data/confluence/attachments 9 9 mysqldump_password = not_a_real_password 10 verbose = True10 verbose = False -
branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications.py
r40893 r40894 99 99 self.verbose = config.getboolean('atlassian_backups', 'verbose') 100 100 101 self.mysqldump_password = _get_str_key_from_section(config, section, 'mysqldump_password') 102 101 103 def target_backup_paths_ok(self) -> bool: 102 104 copy_paths = [ self.host_backup_path … … 150 152 tar_return = self._tar_attachments() 151 153 154 # mysqldump 155 mysqldump_return = self.make_mysql_dump(self.mysqldump_password) 156 152 157 # 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: 154 159 _move_dir_contents_to_dir(tmp_paths, old_paths, self.verbose) 155 160 else: … … 252 257 # do this as the dumper user 253 258 259 print(dump_password) 260 254 261 latest_paths = self.target_paths("latest") 255 262 if not self.target_backup_paths_ok(): … … 270 277 , '--databases', 'jiradb', 'confluencedb' 271 278 ] 279 print(mysqldump_args) 272 280 with open(dump_filepath, "w+") as df: 273 281 mysqldump_process = subprocess.Popen(mysqldump_args, stdout=df, stderr=subprocess.PIPE) … … 278 286 if stde is not None: 279 287 decoded_stderr = stde.decode() 288 print(decoded_stderr) 289 print(decoded_stderr.casefold().find('error'.casefold())) 280 290 if decoded_stderr.casefold().find('error'.casefold()) > -1: 281 291 raise sub_utils.SubprocessError() -
branches/ipp-132_automate_jira_conf_backups/backups/backup_atlassian_applications_test.py
r40893 r40894 25 25 'conf_backup_path' : os.path.join(tmpdir, 'conf_backup_path'), 26 26 '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' 28 29 } 29 30 … … 42 43 assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data" 43 44 assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments" 45 assert ab.mysqldump_password == "not_a_real_password" 44 46 assert ab.verbose is True 45 47 … … 54 56 assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data" 55 57 assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments" 58 assert ab.mysqldump_password == "not_a_real_password" 56 59 57 60 def test_default_arguments(self): … … 65 68 assert ab.jira_attachments_path == "/var/atlassian/application-data/jira/data" 66 69 assert ab.conf_attachments_path == "/var/atlassian/application-data/confluence/attachments" 70 assert ab.mysqldump_password == "not_a_real_password" 67 71 68 72 def test_providing_config_directly(self): … … 76 80 config.set('atlassian_backups', 'jira_attachments_path', 'custom_config6') 77 81 config.set('atlassian_backups', 'conf_attachments_path', 'custom_config7') 82 config.set('atlassian_backups', 'mysqldump_password', 'custom_config8') 78 83 config.set('atlassian_backups', 'verbose', 'False') 79 84 … … 87 92 assert ab.jira_attachments_path == 'custom_config6' 88 93 assert ab.conf_attachments_path == 'custom_config7' 94 assert ab.mysqldump_password == 'custom_config8' 89 95 assert ab.verbose is False 90 96 … … 386 392 """ The mySQL dump tests require the machine on which they are 387 393 running 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 396 In production, a proper password should be set on the server and in the config 397 file. 398 399 To change the password: 390 400 UPDATE 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.394 401 """ 395 402
Note:
See TracChangeset
for help on using the changeset viewer.
