def backup_repository_db(process): process.get_postgres_docker_container() backup_command = ( "su - postgres -c 'pg_dump -U postgres -F t anaconda_repository > " f"{process.postgres_container_repo_backup_path}'" ) # Check for existing backup file and if there remove it if os.path.isfile(f'{process.postgres_system_repo_backup_path}'): os.remove(f'{process.postgres_system_repo_backup_path}') # Backup the repository process.run_command_on_container(process.docker_cont_id, backup_command) # Check for file path and ensure that it created if not os.path.isfile(f'{process.postgres_system_repo_backup_path}'): log.error('Could not find backup file for postgres') raise exceptions.NoPostgresBackup( 'Could not find backup file for postgres' ) # Move the backup to the backup directory sh.mv( f'{process.postgres_system_repo_backup_path}', f'{process.backup_directory}/' )
def backup_postgres_database(process): process.get_postgres_docker_container() backup_command = ( "su - postgres -c 'pg_dumpall -U postgres --clean -f " f"{process.postgres_container_backup_path}'" ) # Check for existing sql file and if there remove it if os.path.isfile(process.postgres_system_backup_path): os.remove(process.postgres_system_backup_path) # Backup the repository process.run_command_on_container(process.docker_cont_id, backup_command) # Check for the file and ensure it is there if not os.path.isfile(process.postgres_system_backup_path): log.error('Could not find backup file for postgres') raise exceptions.NoPostgresBackup( 'Could not find backup file for postgres' ) # Move the backup to the backup directory sh.mv( process.postgres_system_backup_path, f'{process.backup_directory}/' )