DESCRIÇÃO

Procedimento para automação do backup do Alteryx Server (MongoDB e configurações) utilizando Script Batch (.bat) e o Agendador de Tarefas do Windows. 

 

CENÁRIO

  • Software: Alteryx 2021.1 ou superior.

  • S.O.: Microsoft Windows Server 2012 64-bit ou posterior.

  • Pré-requisito: Utilitário 7-Zip instalado para compactação.


CAUSA

Garantir a continuidade do negócio e a integridade dos fluxos, coleções e usuários em caso de falha crítica de hardware ou corrupção de banco de dados. 


SOLUÇÃO



1)Copie o código abaixo em um Bloco de Notas e salve com a extensão .bat (ex: BackupAlteryx.bat).

[!IMPORTANT] Atenção: Edite os caminhos destacados em negrito no bloco de variáveis para corresponderem ao seu servidor.


@echo off
:: --------------------------------------------------------------------------
:: Script de Backup do Alteryx Server v.2.1 - Atualizado 2024
:: Adaptado de: Kevin Powney / Eric Falsken
:: --------------------------------------------------------------------------

:: --- CONFIGURAÇÃO DE VARIÁVEIS (AJUSTE AQUI) ---
SET LogDir=C:\ProgramData\Alteryx\Gallery\Logs\
SET TempDir=C:\Temp\
SET NetworkDir=\\CAMINHO_REDE\Backup_Alteryx\
SET AlteryxService="C:\Program Files\Alteryx\bin\AlteryxService.exe"
SET ZipUtil="C:\Program Files\7-Zip\7z.exe"
SET MaxServiceWait=7200

:: --- GERAÇÃO DE DATA E HORA ---
FOR /f "tokens=2-4 delims=/ " %%a IN ('echo %date%') DO SET datestr=%%c%%b%%a
FOR /f "tokens=1-2 delims=: " %%a IN ('echo %time%') DO SET timestr=%%a%%b
SET datetime=%datestr%_%timestr%

echo Starting backup process... > %LogDir%Backup_%datetime%.log

:: 1. PARAR O SERVIÇO DO ALTERYX
echo Parando AlteryxService... >> %LogDir%Backup_%datetime%.log
%AlteryxService% stop >> %LogDir%Backup_%datetime%.log 2>&1

:: 2. BACKUP DO MONGODB
echo Iniciando dump do MongoDB... >> %LogDir%Backup_%datetime%.log
mkdir %TempDir%ServerBackup_%datetime%
%AlteryxService% emongodump=%TempDir%ServerBackup_%datetime%\Mongo >> %LogDir%Backup_%datetime%.log

:: 3. BACKUP DE ARQUIVOS DE CONFIGURAÇÃO
echo Copiando arquivos de configuração... >> %LogDir%Backup_%datetime%.log
copy %ProgramData%\Alteryx\RuntimeSettings.xml %TempDir%ServerBackup_%datetime% >> %LogDir%Backup_%datetime%.log
%AlteryxService% getserversecret > %TempDir%ServerBackup_%datetime%\ControllerToken.txt

:: 4. REINICIAR O SERVIÇO
echo Reiniciando AlteryxService... >> %LogDir%Backup_%datetime%.log
%AlteryxService% start >> %LogDir%Backup_%datetime%.log

:: 5. COMPACTAR E MOVER PARA REDE
echo Compactando backup... >> %LogDir%Backup_%datetime%.log
%ZipUtil% a %TempDir%ServerBackup_%datetime%.7z %TempDir%ServerBackup_%datetime%\*
move %TempDir%ServerBackup_%datetime%.7z %NetworkDir%

:: 6. LIMPEZA
rmdir /S /Q %TempDir%ServerBackup_%datetime%
echo Processo concluído com sucesso. >> %LogDir%Backup_%datetime%.log

Após salvar o script, siga os passos abaixo no Windows Server:


2) Após salvar a edição do Script vamos adicioná-lo no agendador do Windows, digite no Iniciar "Task Scheduler" e clique em "Create Task"



                                                 

 

3) Na aba General, digite o Nome da tarefa, Descrição , selecionar a opção "Run whether user is logged on or not" e selecione a caixa "Run with highest privileges"



4)Na aba Triggers, clique em "New"




5) Nesta tela abrirá a configuração do cronograma se será executado conforme deseja, após isso clique em "Ok":



6)Na aba Actions, clique em "New"






7) Nesta janela selecione a opção "Start a program" e em "Browse" selecione o Script criado no passo 1 e clique em "Ok"



8) Clique em "OK" na janela "Create Task" para finalizar a criação da tarefa de backup.


DOCUMENTAÇÃO DO FABRICANTE


Backup do Alteryx Server & Recuperação Parte 1: Práticas recomendadas 

Alteryx Server Backup