chore(release): snapshot 1.4.2
This commit is contained in:
38
scripts/setup-backup-agendado.ps1
Normal file
38
scripts/setup-backup-agendado.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
# Script para criar tarefa agendada de backup automatico
|
||||
# Execute como Administrador
|
||||
|
||||
$scriptPath = "g:\Projetos\aggios-app\scripts\backup-db.ps1"
|
||||
$taskName = "Aggios - Backup Automatico DB"
|
||||
|
||||
Write-Host "Configurando backup automatico..." -ForegroundColor Cyan
|
||||
|
||||
# Remove tarefa antiga se existir
|
||||
$existingTask = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
|
||||
if ($existingTask) {
|
||||
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
|
||||
Write-Host "Tarefa antiga removida" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Cria acao (executar o script)
|
||||
$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`""
|
||||
|
||||
# Cria trigger (a cada 6 horas)
|
||||
$trigger = New-ScheduledTaskTrigger -Daily -At "00:00" -DaysInterval 1
|
||||
$trigger2 = New-ScheduledTaskTrigger -Daily -At "06:00" -DaysInterval 1
|
||||
$trigger3 = New-ScheduledTaskTrigger -Daily -At "12:00" -DaysInterval 1
|
||||
$trigger4 = New-ScheduledTaskTrigger -Daily -At "18:00" -DaysInterval 1
|
||||
|
||||
# Configuracoes
|
||||
$principal = New-ScheduledTaskPrincipal -UserId $env:USERNAME -LogonType S4U -RunLevel Highest
|
||||
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
|
||||
|
||||
# Registra a tarefa
|
||||
Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger,$trigger2,$trigger3,$trigger4 -Principal $principal -Settings $settings -Description "Backup automatico do banco de dados Aggios a cada 6 horas"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Backup automatico configurado!" -ForegroundColor Green
|
||||
Write-Host "Frequencia: A cada 6 horas (00:00, 06:00, 12:00, 18:00)" -ForegroundColor Cyan
|
||||
Write-Host "Local dos backups: g:\Projetos\aggios-app\backups" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Para verificar: Abra o Agendador de Tarefas do Windows" -ForegroundColor Yellow
|
||||
Write-Host "Para desabilitar: Run com Administrador: Unregister-ScheduledTask -TaskName '$taskName' -Confirm:`$false" -ForegroundColor Yellow
|
||||
Reference in New Issue
Block a user