Образовательный проект «SnakeProject» Михаила Козлова

Навигация

⇒ Powershell ⇐

CISCO

Voice(Asterisk\Cisco)

Microsoft

Python

SQL\T-SQL

FreeBSD and Nix

Общая

WEB Разработка

ORACLE SQL \ JAVA

Мото

Стрельба, пневматика, оружие

Саморазвитие и психология


Резервное копирование с помощью powershell


#Пути в папки на бэкхосте
$gra = Get-ChildItem \backhostackup_servergrashin 
$adm = Get-ChildItem \backhostackup_serveradministr
$azim = Get-ChildItem \backhostackup_serverazimbekova 
$bil = Get-ChildItem \backhostackup_serverilling 
$dev = Get-ChildItem \backhostackup_serverdevelopment 
$iva = Get-ChildItem \backhostackup_serverIvanyan 
$pg = Get-ChildItem \backhostackup_serverproizvodstvoGrashin 
$sale = Get-ChildItem \backhostackup_serversale 


#Грашин 1с
$gra | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory -body "<h2>Удалены неудачные копии</h2>" > C:powershellscriptsackuplow_files.htm
$gra | where {$_.length -lt 300Kb} | Remove-Item
$gra = Get-ChildItem \backhostackup_servergrashin 

foreach ($cycle in $gra) {    
    $Rgra = $gra | where {$_.Name -gt "base*"} | sort -Descending
    $Rgra[1,2] | ConvertTo-Html -Property Name, Directory -body "<h2>Удалены старые копии</h2>" > C:powershellscriptsackupold_files.htm
    $Rgra[1,2] | Remove-Item
}


 
#Административный отдел СветаЛиана
$adm | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$adm | where {$_.length -lt 300Kb} | Remove-Item
$adm = Get-ChildItem \backhostackup_serveradministr

foreach ($cycle in $adm) {
    $Radm = $adm | where {$_.Name -like "HR*"} | sort -Descending
    $Radm[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Radm[1,2] | Remove-Item
    $Radm = $adm | where {$_.Name -like "adm1*"} | sort -Descending
    $Radm[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Radm[1,2] | Remove-Item
    $Radm = $adm | where {$_.Name -like "adm2*"} | sort -Descending
    $Radm[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Radm[1,2] | Remove-Item
}

#Азимбекова
$azim | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$azim | where {$_.length -lt 300Kb} | Remove-Item
$azim = Get-ChildItem \backhostackup_serverazimbekova 

foreach ($cycle in $azim) {
    $Razim = $azim | where {$_.Name -like "doc*"} | sort -Descending
    $Razim[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Razim[1,2] | Remove-Item
}

#Билинг
$bil | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$bil | where {$_.length -lt 300Kb} | Remove-Item
$bil = Get-ChildItem \backhostackup_serverilling

foreach ($cycle in $bil) {
    $Rbil = $bil | where {$_.Name -like "ivtan*"} | sort -Descending
    $Rbil[1,2] | ConvertTo-Html -Property Name, Directory >> cC:powershellscriptsackupold_files.htm
    $Rbil[1,2] | Remove-Item
    
#Копирование отдельного документа
    $dogin = "\ANIVANANNAUsersivanyanDocumentsПодписанные договора и АКТы.xls"
    $dogout = "\backhostackup_serverilling"
    Copy-Item $dogin -Destination $dogout
}

#Волков
$dev | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$dev | where {$_.length -lt 300Kb} | Remove-Item
$dev = Get-ChildItem \backhostackup_serverdevelopment 

foreach ($cycle in $dev) {
    $Rdev = $dev | where {$_.Name -like "dev*"} | sort -Descending
    $Rdev[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rdev[1,2] | Remove-Item
    $Rdev = $dev | where {$_.Name -like "volkov*"} | sort -Descending
    $Rdev[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rdev[1,2] | Remove-Item
}

#Иванян
$iva | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$iva | where {$_.length -lt 300Kb} | Remove-Item
$iva = Get-ChildItem \backhostackup_serverIvanyan 
    
foreach ($cycle in $iva) {
    $Riva = $iva | where {$_.Name -like "scan*"} | sort -Descending
    $Riva[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Riva[1,2] | Remove-Item
    $Riva = $iva | where {$_.Name -like "СЧЕТА*"} | sort -Descending
    $Riva[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Riva[1,2] | Remove-Item
}

#Тишкин , производственный отдел на сервере
$pg | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$pg | where {$_.length -lt 300Kb} | Remove-Item
$pg = Get-ChildItem \backhostackup_serverproizvodstvoGrashin 

foreach ($cycle in $pg) {
    $Rpg = $pg | where {$_.Name -like "archive*"} | sort -Descending
    $Rpg[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rpg[1,2] | Remove-Item
    $Rpg = $pg | where {$_.Name -like "tishkin*"} | sort -Descending
    $Rpg[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rpg[1,2] | Remove-Item
}

#Продажники
$sale | where {$_.length -lt 300Kb} | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackuplow_files.htm
$sale | where {$_.length -lt 300Kb} | Remove-Item
$sale = Get-ChildItem \backhostackup_serversale 

foreach ($cycle in $sale) {
    $Rsale = $sale | where {$_.Name -like "kadirov*"} | sort -Descending
    $Rsale[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rsale[1,2] | Remove-Item
    $Rsale = $sale | where {$_.Name -like "khamov*"} | sort -Descending
    $Rsale[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rsale[1,2] | Remove-Item
    $Rsale = $sale | where {$_.Name -like "gorbenko*"} | sort -Descending
    $Rsale[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rsale[1,2] | Remove-Item
    $Rsale = $sale | where {$_.Name -like "kulina*"} | sort -Descending
    $Rsale[1,2] | ConvertTo-Html -Property Name, Directory >> C:powershellscriptsackupold_files.htm
    $Rsale[1,2] | Remove-Item
}


Комментарии пользователей

Эту новость ещё не комментировалиНаписать комментарий
Анонимам нельзя оставоять комментарии, зарегистрируйтесь!

Контакты Группа ВК Сборник материалов по Cisco, Asterisk, Windows Server, Python и Django, SQL и T-SQL, FreeBSD и LinuxКод обмена баннерами Видео к IT статьям на YoutubeВидео на другие темы Смотреть
Мои друзья: Советы, помощь, инструменты для сис.админа, статическая и динамическая маршрутизация, FreeBSD

© Snakeproject.ru создан в 2013 году.
При копировании материала с сайта - оставьте ссылку.

Рейтинг@Mail.ru
Рейтинг@Mail.ru Яндекс.Метрика





Поддержать автора и проект