From 311e6fe4456e1831c861f12a1ea02ceff3a46af2 Mon Sep 17 00:00:00 2001 From: DoTheEvo Date: Tue, 8 Oct 2024 23:26:18 +0200 Subject: [PATCH] update --- kopia_backup/readme.md | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/kopia_backup/readme.md b/kopia_backup/readme.md index e297fde..448a547 100644 --- a/kopia_backup/readme.md +++ b/kopia_backup/readme.md @@ -82,6 +82,8 @@ if planning serious use. * **Maintenance** is automatic. * **Retention** of backups - [here's](https://kopia.discourse.group/t/trying-to-understand-retention-policies/164/4) how it works under the hood.
+ [Here](https://kopia.discourse.group/t/kopia-snapshot-retention-policies-demystified/2941) + is more in-depth, it is quite important to read and understand. * **Restore** from backups is most easily done by mounting a snapshot.
Web GUI versions have button for it, cli version can do `sudo kopia mount all /mnt/temp &` * **Tasks** section in gui gets wiped when Kopia closes, info on snapshots run @@ -377,6 +379,70 @@ guide helped move beyond that. It contains more info if one would want to actually run as server repository for other machines.
Also use of [nssm](https://nssm.cc/) is popular. +### Problem with access to password protected network shares + +Kopia as a service runs under SYSTEM user.
+This makes accessing network shares that need credentials problematic. +They need to be somehow mounted on the system for kopia to do its thing. + +Solution that works for me is to mount the shares using powershell `New-SmbGlobalMapping` + +
+ mount-nas-shares.ps1 + + ``` + # Check if the script is running with elevated privileges + if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + # Relaunch the script as administrator + Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit + } + + $user = "nas2\iamuser" + $password = "suppersecretpassword" + + # Create a PSCredential object + $securePassword = ConvertTo-SecureString $password -AsPlainText -Force + $creds = New-Object System.Management.Automation.PSCredential($user, $securePassword) + + # Mount each shared folder using the provided credentials + New-SmbGlobalMapping -LocalPath "Z:" -RemotePath "\\NAS2\blabla" -Credential $creds + New-SmbGlobalMapping -LocalPath "Y:" -RemotePath "\\NAS2\haha" -Credential $creds + New-SmbGlobalMapping -LocalPath "X:" -RemotePath "\\NAS2\zzz" -Credential $creds + + # Restart Explorer + $explorer = Get-Process explorer -ErrorAction SilentlyContinue + if ($explorer) { + Stop-Process -Id $explorer.Id -Force + Start-Process explorer.exe + } + + ``` +
+ +
+ umount-nas-shares.ps1 + + ``` + # Check if the script is running with elevated privileges + if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + # Relaunch the script as administrator + Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit + } + + + # Disconnect each mapped network drive + Remove-SmbGlobalMapping -LocalPath "Z:" -Force + Remove-SmbGlobalMapping -LocalPath "Y:" -Force + Remove-SmbGlobalMapping -LocalPath "X:" -Force + + # Restart Explorer + Stop-Process -Name explorer -ErrorAction SilentlyContinue; Start-Process explorer.exe + + ``` +
+ ## Kopia cli in Windows ![windows_scoop_install_kopia](https://i.imgur.com/UPZFImh.png)