FileSet { # , Name = "VM_lamachine-fs" Include { # (/ "example.com" ) File = "\\|C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -file c:/cmd/search-vm.ps1 -machine lamachine.example.com" Options { # Compression = LZO # RegexFile = ".*/Virtual Machines/.*.bin" Exclude = yes } } }
Param( [string]$level, [string]$machine = "NOEXISTENTVM.example.com" ) Import-Module failoverclusters $backuppath = @() $Cluster = Get-Cluster $ClusterMachines = @() $ClusterMachines += Get-ClusterResource -Cluster $Cluster | where { $_.ResourceType -like "Virtual Machine" } | where { $_.Name -like "*$machine"} | ` select -Property OwnerNode,Name, @{ Name ="VmID";Expression ={ (Get-ClusterParameter -Cluster $Cluster -InputObject $_ | where { $_.Name -eq "VmID" } | select -Property Value).Value } } if ($ClusterMachines.Count -eq 0 ) { "NO MACHINES" exit 2 } foreach ($ClusterMachine in $ClusterMachines){ $VM = Get-VM -ComputerName $ClusterMachine.OwnerNode -Id $ClusterMachine.VmID $path = $VM.Path.Replace('\','/') $backuppath += $path foreach ($HardDrive in $VM.HardDrives){ $drivepath = $HardDrive.Path | Split-Path -Parent $drivepath = $drivepath.Replace('\','/') if ($drivepath -notin $backuppath){ $backuppath += $drivepath } } } $backuppath
#Copyright disclaimer: # Copyright (C) 2015, ITHierarchy Inc (www.ithierarchy.com). ALl rights reserverd. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. Param( [string]$level, [string]$machine = "noexist.example.com", #[string]$prefix = "", [int]$DayOfWeekForFullBackup = 2 ) Import-Module failoverclusters "Processing $machine via $env:computername" $dow = [int]$(get-date).DayOfWeek if ($dow -eq $DayOfWeekForFullBackup){ $prefix="Weekly" } $DateStamp=$(((get-date)).ToString("yyyyMMddTHHmmss")) if ($level -eq "Full"){$Backup=" Bacula -*"}Else{$Backup=" Bacula -$level*"} #$HyperVPath="C:\Hyper-V" #Set path to your Hyper-V Machines to be backed up #Sort out Actual Volume path to VM #$VMDrive=$HyperVPath.Substring(0,1) #$volume=Get-Volume $VMDrive #$TrueHyperVPath=$($HyperVPath.Replace("$($VMDrive):\",$($Volume.path))) #Get List of VMs $Cluster = Get-Cluster # let's initialize it like array (for simplier size check) $ClusterMachines = @() $ClusterMachines += Get-ClusterResource -Cluster $Cluster | where { $_.ResourceType -like "Virtual Machine" } | where { $_.Name -like "*$machine"} | ` select -Property OwnerNode,Name, @{ Name ="VmID";Expression ={ (Get-ClusterParameter -Cluster $Cluster -InputObject $_ | where { $_.Name -eq "VmID" } | select -Property Value).Value } } if ($ClusterMachines.count -gt 1){ "Ambiguous machine name" exit 2 } if ($ClusterMachines.count -ne 1){ "Machine not found: absent, not in failover cluster or something" exit 2 } foreach ($ClusterMachine in $ClusterMachines){ $VM = Get-VM -ComputerName $ClusterMachine.OwnerNode -Id $ClusterMachine.VmID write-host "Working on VM $($vm.Name) @ '$($vm.Path)'" $CurrentSnapShots = $VM | Get-VMSnapshot foreach ($SnapShot in $CurrentSnapShots){ if ($SnapShot.Name -like ("$($prefix)Backup*")){ write-host "Removing VM Checkpoint '$($SnapShot.Name)'" $SnapShot | Remove-VMSnapshot # -ComputerName $ClusterMachine.OwnerNode $LoopCount=0 do { Write-host "Waiting for snapshot '$($SnapShot.name)' to delete..." Start-Sleep -s 10 $LoopCount=$LoopCount+1 }while ($VM.Status -eq "Merging disks" -and $LoopCount -lt 30) } } $label = "$($prefix)Backup-$level-$DateStamp" write-host "Creating Checkpoint $label ($($VM.Name))" $VM | Checkpoint-VM -SnapshotName $label }
#Copyright disclaimer: # Copyright (C) 2015, ITHierarchy Inc (www.ithierarchy.com). ALl rights reserverd. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. Param( [string]$level, [string]$machine = "noexist.example.com", [string]$vmmserver = "vldvmm.example.com" ) Import-Module failoverclusters $Cluster = Get-Cluster $ClusterMachines = Get-ClusterResource -Cluster $Cluster | where { $_.ResourceType -like "Virtual Machine" } | where { $_.Name -like "*$machine"} | ` select -Property OwnerNode,Name, @{ Name ="VmID";Expression ={ (Get-ClusterParameter -Cluster $Cluster -InputObject $_ | where { $_.Name -eq "VmID" } | select -Property Value).Value } } # FIXME foreach foreach ($ClusterMachine in $ClusterMachines){ $VM = Get-VM -ComputerName $ClusterMachine.OwnerNode -Id $ClusterMachine.VmID write-host "Working on VM $($vm.Name) @ '$($vm.Path)'" $CurrentSnapShots = $VM | Get-VMSnapshot foreach ($SnapShot in $CurrentSnapShots){ if ($SnapShot.Name -like ("Backup*")){ write-host "Removing VM Checkpoint '$($SnapShot.Name)'" $SnapShot | Remove-VMSnapshot # -ComputerName $ClusterMachine.OwnerNode $LoopCount=0 do { Write-host "Waiting for snapshot '$($SnapShot.name)' to delete..." Start-Sleep -s 10 $LoopCount=$LoopCount+1 }while ($VM.Status -eq "Merging disks" -and $LoopCount -lt 30) } } }
ls /dev/tape/by-id/
, with the suffix "-nst" - writing drive, without it - a robot avto-changer.Prefer Mounted Volumes
to No
You can write in two different pools without problems and an overhead projector. label barcodes storage=mylittlestorage slot=1 pool=Scratch
update volume=KYF389L6 volstatus=Used
update volume=KYF389L6 pool=YetAnotherPool
label
does not work (“error: already labeled”), there is an add
command, but in my case it caused problems, after which it was impossible to use the cassette. In this case, such a one-liner was born (it is executed in bash on the sd server, the bareos-sd itself must be stopped): mtx -f /dev/sg10 load 25 && mt -f /dev/st0 rewind && mt -f /dev/st0 weof && mt -f /dev/st0 rewind && mtx -f /dev/sg10 unload
mt -f /dev/st0 offline
Device { Name = Drive-0 ... # Maximum Concurrent Jobs = 20 Spool Directory = /mnt/backup/spool Maximum Spool Size = 1950 G Maximum Job Spool Size = 1200 G }
JobDefs { Name = "SundayTape" ... Spool Data = Yes }
Allow Mixed Priority
) #!/bin/bash RED='\033[0;31m' NC='\033[0m' # No Color GREEN='\033[0;32m' YELLOW='\033[0;33m' JOBS=`su - postgres -c "psql -d bareos -c \"WITH summary AS ( SELECT name,jobstatus,jobid, ROW_NUMBER() OVER(PARTITION BY name ORDER BY starttime DESC) AS rk FROM job p WHERE starttime > current_date - INTERVAL '5 days') SELECT s.* FROM summary s WHERE s.rk=1;\"" | grep "1$" | sed 's/ //g'` #echo "$JOBS" for job in $JOBS; do jobstatus=`echo $job | cut -d '|' -f2` jobname=`echo $job | cut -d '|' -f1` jobid=$(echo $job | cut -d '|' -f3) if [ "$jobstatus" == "R" ]; then printf "%-30s" "$jobname ($jobid)" echo -e "$YELLOW running$NC ($jobstatus)" elif [ "$jobstatus" == "W" ]; then printf "%-30s" "$jobname ($jobid)" echo -e "$YELLOW warning$NC ($jobstatus)" elif [ "$jobstatus" == "T" ]; then if [[ $1 == "printall" ]]; then printf "%-30s" "$jobname ($jobid)" echo -e "$GREEN OK$NC ($jobstatus)" fi else printf "%-30s" "$jobname ($jobid)" echo -e "$RED failed$NC ($jobstatus)" fi done
#!/bin/bash JOBS=`su - postgres -c "psql -d bareos -c \" SELECT name,starttime,jobstatus FROM job p WHERE starttime > current_date - INTERVAL '62 days' AND name = '$1' ORDER BY starttime DESC LIMIT 1;\"" | sed 's/ //g' | grep "|.$"` for job in $JOBS; do jobname=`echo $job | cut -d '|' -f1` jobstatus=`echo $job | cut -d '|' -f3` if [ "$jobstatus" == "E" ] || [ "$jobstatus" == "f" ]; then #echo "Job $jobname failed ($jobstatus)." echo "3" exit elif [ "$jobstatus" == "W" ]; then #echo "Job $jobname with warning ($jobstatus)." echo "1" exit elif [ "$jobstatus" != "T" ] && [ "$jobstatus" != "R" ]; then #echo "Job $jobname not ok ($jobstatus)." echo "2" exit elif [ "$jobfiles" == 0 ] || [ "$jobbytes" == 0 ] ; then #echo "Job $jobname is empty." echo "4" exit else echo "0" exit fi done
#!/bin/bash FIRST=true JOBS=$(echo "show jobs" | bconsole | grep "^ *Name = \|Enabled = no" | sed 'N;/\n Enabled = no/d;P;D' | grep -v -e "-test\"$" | cut -d'=' -f 2 | grep -o "[a-zA-Z0-9_-]*" ) echo '{ "data": [' for job in $JOBS; do if [ "$FIRST" = false ]; then echo -n "," fi FIRST=false echo "" echo " {" echo " \"{#JOBNAME}\": \"$job\"" echo -n " }" done echo ' ] }'
status storage=
command, but for some reason it didn’t occur to me to make the status director
. A convenient summary was found there (and if the watch "echo 'status director' | bconsole"
, then it is practically a dashboard), its simplicity is especially useful for operators of cassette changers.Source: https://habr.com/ru/post/275259/
All Articles