diff --git a/bitwardenBackup.py b/bitwardenBackup.py index 3f4b432..1d77c2a 100644 --- a/bitwardenBackup.py +++ b/bitwardenBackup.py @@ -458,9 +458,9 @@ if __name__ == "__main__": # export to csv and json logger.info("Exporting vault to both CSV and JSON files") logger.debug("Exporting vault to CSV") - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'Bitwarden {} Export {}.csv'.format(email, datetime_string)) , '--format', 'csv'], capture_output=True).stdout).decode()) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, 'Bitwarden {} Export {}.csv'.format(email, datetime_string)) , '--format', 'csv'], capture_output=True).stdout).decode()) logger.debug("Exporting vault to JSON") - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(script_directory, 'Bitwarden {} Export {}.json'.format(email, datetime_string)), '--format', 'json'], capture_output=True).stdout).decode()) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--output', os.path.join(working_directory, 'Bitwarden {} Export {}.json'.format(email, datetime_string)), '--format', 'json'], capture_output=True).stdout).decode()) # looking for Organizations # look for organizations @@ -471,9 +471,9 @@ if __name__ == "__main__": for organization in bitwarden_organizations: logger.info("Exporting organization {} vault to both CSV and JSON files".format(organization['name'])) logger.debug("Exporting organization vault to CSV") - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(script_directory, 'Bitwarden Organization {} Export {}.csv'.format(organization['name'], datetime_string)) , '--format', 'csv'], capture_output=True).stdout).decode()) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, 'Bitwarden Organization {} Export {}.csv'.format(organization['name'], datetime_string)) , '--format', 'csv'], capture_output=True).stdout).decode()) logger.debug("Exporting organization vault to JSON") - logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(script_directory, 'Bitwarden Organziation {} Export {}.json'.format(organization['name'], datetime_string)), '--format', 'json'], capture_output=True).stdout).decode()) + logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(working_directory, 'Bitwarden Organziation {} Export {}.json'.format(organization['name'], datetime_string)), '--format', 'json'], capture_output=True).stdout).decode()) logger.info("Downlading attachments...") bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode()) @@ -481,7 +481,7 @@ if __name__ == "__main__": logger.debug("Working on item {} ({})".format(item['name'], item['id'])) if "attachments" in item: logger.debug("Found {} attachments".format(len(item['attachments']))) - attachment_folder_name = os.path.join(script_directory, "attachments", item['name']) + attachment_folder_name = os.path.join(working_directory, "attachments", item['name']) for attachment in item['attachments']: logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['fileName'], attachment_folder_name)) logger.info((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['fileName'])], capture_output=True).stdout).decode())