community
cancel
Showing results for 
Search instead for 
Did you mean: 

alteryx server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Backup script does not move the archive to network storage location

 

Hi All,

 

I created a backup script to carry out the mongoDB backup and move the backup file to the network drive.

 

Script enclosed and log file enclosed for the reference.

 

Script created the MongoDB backup. Screen shot attached.

 

But the script does not move the archive to network storage location and does not clean up local files.

 

Could you please advise me, on how to fix this issue on the below scrip?

 

Regards, Raj.

 

REM @echo off

::-----------------------------------------------------------------------------
:: Set variables for Log and Temp directories
::-----------------------------------------------------------------------------

SET LogDir=D:\ProgramData\Alteryx\BackupLogs\
SET TempDir=D:\AlteryxBackupResources\Temp\
SET NewDir=\\TEST.humour.adroot.bcbd\Alt_Tab_App$\ARCHIVE\CreAnalytics\Alteryx\ServerBackups\

::-----------------------------------------------------------------------------
:: Set Date/Time to a usable format and create log
::-----------------------------------------------------------------------------

FOR /f %%a IN ('WMIC OS GET LocalDateTime ^| FIND "."') DO SET DTS=%%a
SET DateTime=%DTS:~0,4%%DTS:~4,2%%DTS:~6,2%_%DTS:~8,2%%DTS:~10,2%%DTS:~12,2%


echo %date% %time%: Starting backup process > %LogDir%BackupLog%datetime%.log
echo. >> %LogDir%BackupLog%datetime%.log

::-----------------------------------------------------------------------------
:: Stop Alteryx Service
::-----------------------------------------------------------------------------

echo %date% %time%: Stopping Alteryx Service >> %LogDir%BackupLog%datetime%.log
echo. >> %LogDir%BackupLog%datetime%.log

NET STOP AlteryxService >> %LogDir%BackupLog%datetime%.log

::-----------------------------------------------------------------------------
:: Backup MongoDB to local temp directory.
::-----------------------------------------------------------------------------

echo %date% %time%: Starting MongoDB Backup >> %LogDir%BackupLog%datetime%.log
echo. >> %LogDir%BackupLog%datetime%.log

"D:\Alteryx\AlteryxService.exe" emongodump=%TempDir%ServerBackup_%datetime%\Mongo >> %LogDir%BackupLog%datetime%.log

:: pause

::-----------------------------------------------------------------------------
:: Restart Alteryx Service
::-----------------------------------------------------------------------------

echo %date% %time%: Restarting Alteryx Service >> %LogDir%BackupLog%datetime%.log
echo. >> %LogDir%BackupLog%datetime%.log

NET START AlteryxService >> %LogDir%BackupLog%datetime%.log

:: pause

::-----------------------------------------------------------------------------
:: Move archive to network storage location and cleanup local files
::-----------------------------------------------------------------------------

echo. >> %LogDir%BackupLog%datetime%.log
echo %date% %time%: Moving archive to network storage >> %LogDir%BackupLog%datetime%.log
echo. >> %LogDir%BackupLog%datetime%.log

:: Be sure to update the UNC path for the network location to copy the file to.
copy "%TempDir%ServerBackup_%datetime%" "%NewDir%" >> %LogDir%BackupLog%datetime%.log

:: pause

del %TempDir%ServerBackup_%datetime% >> %LogDir%BackupLog%datetime%.log
rmdir /S /Q %TempDir%ServerBackup_%datetime% >> %LogDir%BackupLog%datetime%.log

:: pause

::-----------------------------------------------------------------------------
:: Done
::-----------------------------------------------------------------------------

echo. >> %LogDir%BackupLog%datetime%.log
echo %date% %time%: Backup process completed >> %LogDir%BackupLog%datetime%.log

 

 

 

Backuplog.jpgBackup file not moved.jpg

Alteryx
Alteryx

Hi,

 

I think it may be due to your copy command being the folder location and not the file. 

 

Copy is made to copy files and not directories. 

 

You would either need to update the command to be the file name, or change the command to be robocopy command. Like:

 

robocopy "%TempDir%ServerBackup_%datetime%" "%NewDir%" /e >> %LogDir%BackupLog%datetime%.log

With the /e being the argument for all files and folders.

 

Hopefully that should work for you