Skip to content

Commit 156554a

Browse files
committed
Add documentation #1
1 parent fc1fbe0 commit 156554a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Execute the following to backup all git repositories of a GitHub user into the d
2727
.\backup_github_repositories.ps1 -userName "user" -backupDirectory "C:\myBackupDirectory"
2828
```
2929

30+
### Backup all git repositories with a maximum concurrency of 2
31+
Execute the following to backup all git repositories of a GitHub user into the subdirectory `./YYYY-MM-DD/` with a maximum concurrency of 2 background jobs.
32+
```PowerShell
33+
.\backup_github_repositories.ps1 -userName "user" -backupDirectory "C:\myBackupDirectory" -maxConcurrency 2
34+
```
35+
3036
### Get detailed help
3137
Execute the following command to get detailed help.
3238
```PowerShell

backup_github_repositories.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ Specifies the optional GitHub organisation name.
1919
.PARAMETER backupDirectory
2020
Overrides the default backup directory.
2121
22+
.PARAMETER maxConcurrency
23+
Overrides the default concurrency of 8.
24+
2225
.EXAMPLE
2326
.\backup_github_repositories.ps1 -userName "user" -userSecret "secret"
2427
2528
.EXAMPLE
2629
.\backup_github_repositories.ps1 -userName "user" -userSecret "secret" -organisationName "organisation"
2730
2831
.EXAMPLE
29-
.\backup_github_repositories.ps1 -backupDirectory "C:\myBackupDirectory"
32+
.\backup_github_repositories.ps1 -backupDirectory "C:\myBackupDirectory" -maxConcurrency 1
3033
#>
3134

3235
[CmdletBinding(
@@ -157,7 +160,7 @@ ForEach ($repository in $repositories) {
157160
while ($true) {
158161

159162
# Handle completed jobs as soon as possible.
160-
$completedJobs = $(Get-Job -State Completed | Where-Object {$_.Name.Contains("backup_github_repositories")})
163+
$completedJobs = $(Get-Job -State Completed)
161164
ForEach ($job in $completedJobs) {
162165
$job | Receive-Job
163166
$job | Remove-Job
@@ -200,9 +203,7 @@ ForEach ($repository in $repositories) {
200203
$directory = $(Join-Path -Path $backupDirectory -ChildPath "$($repository.name).git")
201204

202205
Write-Host "[$($repository.full_name)] Starting backup to ${directory}..." -ForegroundColor "DarkYellow"
203-
Start-Job $scriptBlock -Name "backup_github_repositories" `
204-
-ArgumentList $repository.full_name, $directory `
205-
| Out-Null
206+
Start-Job $scriptBlock -ArgumentList $repository.full_name, $directory | Out-Null
206207
break
207208
}
208209
}

0 commit comments

Comments
 (0)