Skip to content

Instantly share code, notes, and snippets.

View tdewin's full-sized avatar

tdewin

View GitHub Profile
@tdewin
tdewin / gist-vbr-proxy-to-job-location-mapping.ps1
Created May 19, 2020 17:03
Veeam Backup & Replication : Map proxies to jobs based on [location:mylocation] in description
asnp veeampssnapin
$reglocation = "\[location:([a-zA-Z0-9]+)\]"
$proxies = Get-VBRViProxy | Group-Object -AsHashTable -AsString -property { if ($_.description -match $reglocation) { $matches[1].trim() } else { "unspecified" }}
foreach($proxygroup in $proxies.GetEnumerator()) {
Write-host ("Found location {0} with {1} proxies" -f $proxygroup.Name,$proxygroup.Value.Count)
}
@tdewin
tdewin / get-clihistory.ps1
Created August 5, 2020 10:52
Copy the command history for powershell to keyboard for blogging, filter out history command
function get-clihistory { $h = history | ? { -not ( $_.CommandLine -match "^(history|get-clihistory)") };$h.CommandLine -join "`n" | Set-Clipboard }
<#
Make a folder "uuid" and in this folder a file "uuid.txt". Paste in the content of the variable $lookfor (for example d:\uuid\uuid.txt contains "adfdca28-12ad-11eb-adc1-0242ac120002"). You can have different uuid on different disk for different scripts
#>
$lookfor = "adfdca28-12ad-11eb-adc1-0242ac120002"
$vols = Get-Volume | ? { $_.DriveLetter -ne $null }
$disk = $null
foreach($vol in $vols) {
$uuidpath = ("{0}:\{1}" -f $vol.driveletter,"uuid\uuid.txt")
if (Test-Path $uuidpath) {
@tdewin
tdewin / minio-dev.yaml
Last active April 18, 2021 21:26
Kubernetes minio for dev. This is really not a good thing to run in production (but my lab is not production so who cares). Use "kubectl -n minios3 logs minios3-0" to get info. Use "kubectl -n minios3 get svc". In the cluster, you can use minios3.minios3 if you have dns.
apiVersion: v1
kind: Namespace
metadata:
name: minios3
---
apiVersion: v1
kind: Service
metadata:
name: minios3
labels:
@tdewin
tdewin / extenddisk-vm-ubuntu.sh
Last active August 24, 2021 14:57
how to extend the default volume so i don't always have to google
echo '1' > /sys/class/scsi_disk/2\:0\:0\:0/device/rescan
fdisk /dev/sda #create new partition with n and all default + w to write out, eg next partition 4
lvm vgextend ubuntu-vg /dev/sda4
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/ubuntu-vg/ubuntu-lv
#or if volume group already absorbed everything
#sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
#sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
@tdewin
tdewin / files-in-object.ps1
Created November 16, 2021 13:23
files in object storage for veeam vbr
#Run as admin
$name = "VMs to AWS"
Connect-VBRServer -server localhost
$backup = Get-VBRBackup -name $name
$rps = $backup | Get-VBRRestorePoint | Sort-Object -Property CreationTime
$cloudstat = @()
foreach ($rp in $rps) {
$storage = $rp.GetStorage()
@tdewin
tdewin / kasten-ubuntu-lab.sh
Last active January 14, 2022 22:36
Kasten demo lab on ubuntu microk8s with openebs persistent volume (zfs based) and minio s3 storage
#!/usr/bin/bash
# first upload (might not work)
# make sure your vm has a second disk /dev/sdb that is completely empty (used for the zfs pool)
# you need some free ip range in your environment eg 192.168.0.40 is your server, then supply 192.168.0.41 for first and 192.168.0.49 for last if all the ips in between are free
ZFSDISK=/dev/sdb
ADMINNAME=admin
KASTENTOKENAUTH=0
if [ ! $(ls $ZFSDISK) ];then echo "ZFSDisk $ZFSDISK not found";exit -1 ;fi
@tdewin
tdewin / chrony.part.conf
Last active April 29, 2022 09:32
Curated list of NTS
# NTS list
# https://www.cloudflare.com/time/
# cloudflare is an anycast server and should select a server that is close to your location
server time.cloudflare.com iburst nts
# https://www.netnod.se/time-and-frequency/how-to-use-nts
# ntp.se should be anycast
server nts.ntp.se nts iburst
server nts.netnod.se nts iburst
@tdewin
tdewin / support-backup.ps1
Last active September 16, 2022 08:39
Backup of Veeam Backup & Replication Database
$bpath = "c:\temp\"
New-Item -Type Directory $bpath -ErrorAction ignore
$datestr = ("{0}" -f (Get-Date -Format "yyyyMMdd-hhmmss"))
$bdatepath = join-path -Path $bpath -ChildPath ("veeambackup-{0}" -f $datestr)
New-Item -Type Directory $bdatepath
$props = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Veeam\Veeam Backup and Replication\'
$fpath = join-path -Path $bdatepath -childpath ("sqldump-{0}-{1}.bak" -f $props.SqlDatabaseName,$datestr)
Backup-SqlDatabase -ServerInstance ("{0}\{1}" -f $props.SqlServerName,$props.SqlInstanceName) -Database $props.SqlDatabaseName -BackupFile $fpath