Skip to content

Commit b55c9e1

Browse files
committed
Added Backup cmdlets
1 parent 1275818 commit b55c9e1

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function Get-RaindropBackup {
2+
param (
3+
[Parameter(Mandatory)]
4+
[string] $ApiToken
5+
)
6+
7+
$url = "$Global:RaindropBaseUrl/backups"
8+
$headers = Get-RaindropAuthHeader -ApiToken $ApiToken
9+
10+
try {
11+
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
12+
return $response.items
13+
}
14+
catch {
15+
Write-Error "Failed to retrieve projects: $_"
16+
}
17+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function New-RaindropBackup {
2+
param (
3+
[Parameter(Mandatory)]
4+
[string] $ApiToken
5+
)
6+
7+
$url = "$Global:RaindropBaseUrl/backup"
8+
$headers = Get-RaindropAuthHeader -ApiToken $ApiToken
9+
10+
try {
11+
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
12+
Write-Host $response.message
13+
return $response.result
14+
}
15+
catch {
16+
Write-Error "Failed to retrieve projects: $_"
17+
}
18+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function Save-RaindropBackup {
2+
param (
3+
[Parameter(Mandatory)]
4+
[string] $ApiToken,
5+
6+
[Parameter(Mandatory = $true)]
7+
[string] $id = 0,
8+
9+
[Parameter(Mandatory = $true)]
10+
[ValidateSet("csv", "html")]
11+
[string] $format,
12+
13+
[Parameter(Mandatory = $false)]
14+
[string] $OutFile
15+
)
16+
17+
$url = "$Global:RaindropBaseUrl/backup/$id.$format"
18+
$headers = Get-RaindropAuthHeader -ApiToken $ApiToken
19+
20+
try {
21+
if ([string]::IsNullOrEmpty($OutFile)) {
22+
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
23+
return $response
24+
}
25+
else {
26+
Invoke-WebRequest -Uri $url -Headers $headers -Method Get -OutFile $OutFile
27+
}
28+
}
29+
catch {
30+
Write-Error "Failed to retrieve projects: $_"
31+
}
32+
}

0 commit comments

Comments
 (0)