You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: GithubBackup/Class/Globals.cs
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,6 @@
1
1
usingSystem;
2
2
usingSystem.Collections.Generic;
3
3
usingSystem.Net.Mail;
4
-
usingLibGit2Sharp;
5
4
6
5
namespaceGithubBackup.Class
7
6
{
@@ -25,6 +24,8 @@ public class Globals
25
24
publicstaticbool_allReposNotForks;// backup all repos from Github if true - default is false
26
25
publicstaticbool_allReposNotForksAndIsOwner;// backup all repos from Github if true - default is true as most common use case is to backup own repos and not forks from others repos
27
26
publicstaticbool_excludeBranchDependabot;// exclude branches with "dependabot" in it from backup if true - default is true
27
+
publicstaticbool_backupRepoMetadata;// backup metadata from repo if true - default is false
28
+
publicstaticbool_backupReleasedata;// backup release from repo if true - default is false
28
29
//public static string _alloriginalBranches; // backup all original branches from repo
publicstaticint_repoCount;// count repos from Github
41
43
publicstaticint_repoBackupPerformedCount;// count repo items from Github
42
44
publicstaticint_repoBackupPerformedBranchCount;// count repo (branches) items from Github
@@ -46,12 +48,14 @@ public class Globals
46
48
publicstaticbool_isBackupOk;// check if backup is ok or not state
47
49
publicstaticstring_repoCountStatusText;// text to display in email report
48
50
publicstaticstring_isDaysToKeepNotDefaultStatusText;// text to display in email report if days to keep backup is not default value (30 days)
51
+
publicstaticstring_isdaysToKeepLogFilesOptionDefaultStatusText;// text to display in email report if days to keep log files is not default value (30 days)
49
52
publicstaticstring_totalBackupsIsDeletedStatusText;// text to display in email report if backups is deleted
50
53
51
54
// Set Global variables for cleanup
52
55
publicstaticint_totalBackupsIsDeleted;// count of total backups deleted
53
56
publicstaticint_oldLogFilesToDeleteCount;// count of old log files deleted
54
57
publicstaticbool_oldLogfilesToDelete;// delete old log files if true - default is false and function is not used
58
+
publicstaticint_daysToKeepLogFilesOption;// number of days to keep log files in log folder before deleting it - default is 30 days if not set
55
59
56
60
// Set Global variables for email
57
61
publicstaticstring_mailto;// email address to send email to
@@ -73,4 +77,4 @@ public class Globals
73
77
publicstaticList<string>repocountelements=newList<string>();// list of repos to backup from Github - used for email report
74
78
publicstaticList<string>repoitemscountelements=newList<string>();// list of repo items to backup from Github - used for email report
varbranchNames=BackupService.GetBranchesForRepository(client,repo);// Replace with your method to get branches
19
+
20
+
Console.WriteLine($"Processing metadata for repository '{repo.FullName}' for backup up to: '{repoDestinationBackupMetadataFilePath}'");
21
+
Message($"Processing metadata for repository '{repo.FullName}' for backup up to: '{repoDestinationBackupMetadataFilePath}'",EventType.Information,1000);
22
+
23
+
// Save metadata for the repository if it has any branches
Console.WriteLine($"Done processing metadata for repository '{repo.FullName}' for backup up to: '{repoDestinationBackupMetadataFilePath}'");
32
+
Message($"> Done processing metadata for repository '{repo.FullName}' for backup up to: '{repoDestinationBackupMetadataFilePath}'",EventType.Information,1000);
33
+
}
34
+
// Skip further processing if the repository is empty
35
+
else
36
+
{
37
+
Console.WriteLine($"Skipped saving metadata for empty repository '{repo.FullName}' - if there was data to backup, repository metadata has been saved to: '{repoDestinationBackupMetadataFilePath}'");
38
+
Message($"! Skipped saving metadata for empty repository '{repo.FullName}' - if there was data to backup, repository metadata has been saved to: '{repoDestinationBackupMetadataFilePath}'",EventType.Warning,1001);
39
+
return;// Skip further processing if the repository is empty
40
+
}
41
+
}
42
+
catch(Exceptionex)
43
+
{
44
+
// Handle the exception (log or display an error message)
45
+
Console.WriteLine($"Error saving metadata for repository '{repo.FullName}': {ex.Message}");
46
+
Message($"Error saving metadata for repository '{repo.FullName}': {ex.Message}",EventType.Error,1001);
47
+
48
+
// Increment the _errors integer
49
+
Globals._errors++;// Increment the _errors integer
0 commit comments