Beispiel #1
0
        public override bool Backup(string rootBackupDir)
        {
            if (!IsAuthorized)
            {
                LOGGER.Error("Unable to backup Bitbucket API");
                return(false);
            }

            OnStartAllBackups();

            CanBackup = false;
            string currentRepoName     = null;
            string serviceSubFolderDir = Path.Combine(rootBackupDir, m_serviceNameFolder);

            try
            {
                List <Repository> repos = m_bitbucketAPI.GetAllRepos(m_bitbucketAPI.Username);
                foreach (Repository repo in repos)
                {
                    BackupReposDto backupRepoConfig = m_backupRepos?.FirstOrDefault(x => x.RepositoryName == repo.name);
                    if (backupRepoConfig != null && !backupRepoConfig.ShouldBackup)
                    {
                        continue;
                    }

                    OnRepoStartBackup(repo.name);
                    currentRepoName = repo.name;

                    if (BackupSingleRepository(serviceSubFolderDir, repo.name))
                    {
                        OnRepoBackupSucceeded(repo.name);
                    }
                    else
                    {
                        LOGGER.Error($"Unable to backup {repo.name}");
                        OnRepoBackupFailed(repo.name);
                    }

                    CompletedReposCount++;
                }
            }
            catch (Exception e)
            {
                LOGGER.Fatal($"Exception occured when trying to backup repository '{currentRepoName}'{Environment.NewLine}{e.ToString()}");
            }

            OnCompletedAllBackups();

            CanBackup = true;
            return(true);
        }
Beispiel #2
0
        public override bool Backup(string rootBackupDir)
        {
            if (!IsAuthorized)
            {
                LOGGER.Error("Unable to backup Github API");
                return(false);
            }

            CanBackup = false;
            string currentRepoName     = string.Empty;
            string serviceSubFolderDir = Path.Combine(rootBackupDir, m_serviceNameFolder);

            try
            {
                List <Repository> repos = m_githubApiService.GetAllRepositories();
                foreach (Repository repo in repos)
                {
                    BackupReposDto backupRepoConfig = m_backupRepos?.FirstOrDefault(x => x.RepositoryName == repo.Name);
                    if (backupRepoConfig != null && !backupRepoConfig.ShouldBackup)
                    {
                        continue;
                    }

                    OnRepoStartBackup(repo.Name);
                    currentRepoName = repo.Name;

                    if (BackupSingleRepository(serviceSubFolderDir, repo.Name))
                    {
                        OnRepoBackupSucceeded(repo.Name);
                    }
                    else
                    {
                        LOGGER.Error($"Unable to backup {repo.Name}");
                        OnRepoBackupFailed(repo.Name);
                    }

                    CompletedReposCount++;
                }
            }
            catch (Exception e)
            {
                LOGGER.Fatal($"Unable to backup repository {currentRepoName}");
            }

            CanBackup = true;
            return(true);
        }