-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup-jellyfin.ps1
57 lines (38 loc) · 2.13 KB
/
backup-jellyfin.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Simple Jellyfin server backup script for windows..
# Source: https://github.com/DrewTheGiraffe/JellyfinBackup/edit/main/backup-jellyfin.ps1
$date = Get-Date -Format "MM-dd-yyyy"
$backupname = "JellyFinServer_Backup-${date}"
$public_backup_path = "${env:USERPROFILE}\Desktop"
# Stop server before backing up to avoid file corruption
Get-Process | Where {$_.ProcessName -like "*jellyfin*"} | Stop-Process -Force
# Check for process existance before running backup...
$verify = (Get-Process | Where {$_.ProcessName -like "*jellyfin*"} | select $_)
If ($null -eq $verify) {
$DestinationPath = "$public_backup_path\$backupname"
If (Test-Path $DestinationPath -eq $false) {
New-Item -Path "${env:USERPROFILE}\Desktop" -Name $backupname -ItemType Directory -Force
}
If (Test-Path -Path "C:\Program Files\Jellyfin") {
Copy-Item -Path "C:\Program Files\Jellyfin" -Destination "$DestinationPath\JellyfinProgramFiles" -Verbose -Recurse -Force
}
If (Test-Path -Path "C:\ProgramData\Jellyfin") {
Copy-Item -Path "C:\ProgramData\Jellyfin" -Destination "$DestinationPath\JellyfinProgramData" -Verbose -Recurse -Force
}
If (Test-Path -Path "C:\Users\user1\Documents\mediashare") {
Copy-Item -Path "C:\Users\user1\Documents\mediashare" -Destination "$DestinationPath\customimages" -Verbose -Recurse -Force
Clear-Host
Start-Sleep -Seconds 2
}
Compress-Archive -Path "$public_backup_path\$backupname" -DestinationPath "$public_backup_path\$backupname.zip" -Verbose -Force
Remove-Item -Path "$public_backup_path\$backupname" -Recurse -Force
Start-Sleep -Milliseconds 100
Clear-Host
Write-Host "Created backup [" -NoNewline
Write-Host "${backupname}.zip" -NoNewline -ForegroundColor Green
Write-Host "] to $public_backup_path"
write-Host "`nYou will need to start jellyfin manually." -ForegroundColor Green
}
# start server when backup is finished
If (Test-Path -Path "C:\Program Files\Jellyfin\Server") {
Start-Process -FilePath "C:\Program Files\Jellyfin\Server" -ArgumentList ".\jellyfin.exe"
}