update
parent
d8f7c0db7b
commit
6864cb83ba
@ -1,54 +0,0 @@
|
||||
@echo off
|
||||
|
||||
:: checking if the script is run as administrator
|
||||
net session >nul 2>&1
|
||||
if %errorLevel% == 0 (
|
||||
echo - Success: Administrative permissions confirmed.
|
||||
) else (
|
||||
echo - RUN AS ADMINISTRATOR
|
||||
pause
|
||||
exit /B
|
||||
)
|
||||
|
||||
echo - powershell ExecutionPolicy changing to Bypass
|
||||
powershell.exe Set-ExecutionPolicy -ExecutionPolicy Bypass
|
||||
|
||||
echo - checking if C:\Kopia folder exists, creating it if not
|
||||
if not exist "C:\Kopia\" (
|
||||
mkdir C:\Kopia
|
||||
)
|
||||
|
||||
if exist "C:\Kopia\kopia_server_start.cmd" (
|
||||
echo - C:\Kopia\kopia_server_start.cmd exists, renaming it with random suffix
|
||||
ren "C:\Kopia\kopia_server_start.cmd" "kopia_backup_scipt_%random%.ps1"
|
||||
)
|
||||
|
||||
echo - copying files to C:\Kopia
|
||||
robocopy "%~dp0\" "C:\Kopia" "kopia.exe" /NDL /NJH /NJS
|
||||
robocopy "%~dp0\" "C:\Kopia" "kopia_server_start.cmd" /NDL /NJH /NJS
|
||||
robocopy "%~dp0\" "C:\Kopia" "win_vss_before.ps1" /NDL /NJH /NJS
|
||||
robocopy "%~dp0\" "C:\Kopia" "win_vss_after.ps1" /NDL /NJH /NJS
|
||||
echo.
|
||||
|
||||
if exist C:\Windows\System32\Tasks\kopia_server_backup_start (
|
||||
echo - scheduled task with that name already exists, skipping
|
||||
echo - delete the task in taskschd.msc if you want fresh import
|
||||
) else (
|
||||
echo - importing scheduled task that starts Kopia Server on boot
|
||||
schtasks /Create /XML "%~dp0\kopia_server_backup_start.xml" /tn "kopia_server_backup_start"
|
||||
)
|
||||
|
||||
echo - starting Kopia Server
|
||||
schtasks /run /tn kopia_server_backup_start
|
||||
|
||||
echo - copying link to Desktop
|
||||
robocopy "%~dp0\" "%USERPROFILE%\Desktop" "Kopia.url" /NDL /NJH /NJS
|
||||
|
||||
echo.
|
||||
echo --------------------------------------------------------------
|
||||
echo.
|
||||
echo DEPLOYMENT DONE
|
||||
echo KOPIA SERVER CAN NOW BE FIND AT WEB PAGE: localhost:51515
|
||||
echo A LINK SHOULD BE ON YOUR DESKTOP
|
||||
echo.
|
||||
pause
|
@ -1,6 +0,0 @@
|
||||
[InternetShortcut]
|
||||
URL=http://localhost:51515/
|
||||
IDList=
|
||||
HotKey=0
|
||||
[{000214A0-0000-0000-C000-000000000046}]
|
||||
Prop3=19,2
|
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
chdir /d C:\Kopia
|
||||
start /B kopia server start --insecure --address=127.0.0.1:51515 --server-username=admin --server-password=aaa
|
@ -1,18 +0,0 @@
|
||||
if ($args.Length -eq 0) {
|
||||
$kopiaSnapshotId = $env:KOPIA_SNAPSHOT_ID
|
||||
} else {
|
||||
$kopiaSnapshotId = $args[0]
|
||||
}
|
||||
|
||||
if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
$mountPoint = Get-Item "${PSScriptRoot}\${kopiaSnapshotId}"
|
||||
$mountedVolume = $mountPoint.Target
|
||||
|
||||
cmd /c rmdir $mountPoint
|
||||
Get-CimInstance -ClassName Win32_ShadowCopy | Where-Object { "$($_.DeviceObject)\" -eq "\\?\${mountedVolume}" } | Remove-CimInstance
|
||||
} else {
|
||||
Start-Process 'powershell' '-f', $MyInvocation.MyCommand.Path, $kopiaSnapshotId -Verb RunAs -WindowStyle Hidden -Wait
|
||||
if ($proc.ExitCode) {
|
||||
exit $proc.ExitCode
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
if ($args.Length -eq 0) {
|
||||
$kopiaSnapshotId = $env:KOPIA_SNAPSHOT_ID
|
||||
$kopiaSourcePath = $env:KOPIA_SOURCE_PATH
|
||||
} else {
|
||||
$kopiaSnapshotId = $args[0]
|
||||
$kopiaSourcePath = $args[1]
|
||||
}
|
||||
|
||||
$sourceDrive = Split-Path -Qualifier $kopiaSourcePath
|
||||
$sourcePath = Split-Path -NoQualifier $kopiaSourcePath
|
||||
# use Kopia snapshot ID as mount point name for extra caution for duplication
|
||||
$mountPoint = "${PSScriptRoot}\${kopiaSnapshotId}"
|
||||
|
||||
if (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
|
||||
$shadowId = (Invoke-CimMethod -ClassName Win32_ShadowCopy -MethodName Create -Arguments @{ Volume = "${sourceDrive}\" }).ShadowID
|
||||
$shadowDevice = (Get-CimInstance -ClassName Win32_ShadowCopy | Where-Object { $_.ID -eq $shadowId }).DeviceObject
|
||||
if (-not $shadowDevice) {
|
||||
# fail the Kopia snapshot early if shadow copy was not created
|
||||
exit 1
|
||||
}
|
||||
|
||||
cmd /c mklink /d $mountPoint "${shadowDevice}\"
|
||||
} else {
|
||||
$proc = Start-Process 'powershell' '-f', $MyInvocation.MyCommand.Path, $kopiaSnapshotId, $kopiaSourcePath -PassThru -Verb RunAs -WindowStyle Hidden -Wait
|
||||
if ($proc.ExitCode) {
|
||||
exit $proc.ExitCode
|
||||
}
|
||||
}
|
||||
|
||||
Write-Output "KOPIA_SNAPSHOT_PATH=${mountPoint}${sourcePath}"
|
Loading…
Reference in New Issue