1) I installed 7zip on the server that runs the backups.
2) I wrote the main bit of code in a batch file called "backupSlave.bat"
Code: Select all
:: Call this file with two arguments - the source folder (first argument) and the destination folder (second argument)
:: e.g. backupSlave.bat C:\TM1\MyServer\Data G:\Backups\MyServer
:: This file will create a timestamped folder within the destination folder, copy the source into the destination
:: run a zip then delete the copied folder.
::@echo off
:: Retrieve the two parameters which will be the directory to be backed up
:: and the directory to back it up into respectively
set "srcFolder=%~1"
set "destnFolder=%~2"
if "%srcFolder%"=="" (
set errorMsg=no srcFolder provided
goto :exitwitherror
) else (
echo srcFolder set to %srcFolder%
)
if "%destnFolder%"=="" (
set errorMsg=no destnFolder provided
goto :exitwitherror
) else (
echo destnFolder set to %destnFolder%
)
set hh=%time:~-11,2%
set /a hh=%hh%+100
set hh=%hh:~1%
Set dateseed=%date:~10,4%%date:~7,2%%date:~4,2%-%hh%%time:~3,2%
set targetDir=%destnFolder%\%dateseed%
mkdir %targetDir%
:: copy the data. /C switch tells it to carry out even if there are sharing violations (common with tm1s.log)
xcopy "%srcFolder%" "%targetDir%" /e /C
:: zip it up
"C:\Program Files\7-Zip\7z.exe" a -tzip ""%targetDir%".zip" "%targetDir%" -r
:: Remove the unzipped directory
RD /S /Q "%targetDir%"
:: Avoid error handler
goto :exitwithouterror
:exitwitherror
echo An error occurred - %errorMsg%
:exitwithouterror
Code: Select all
:: Calls the slave to backup the source folder (first argument) to the destination folder (second argument)
:: the slave will create a timestamped folder within the destination folder
E:\TM1\scripts\backupSlave.bat \\server\e$\TM1\MyServer G:\Backups\MyServer
ExecuteCommand('E:\TM1\scripts\backupMaster.bat', 0);
Not sure if that's the best way, but it's been working for me for about a year now and has saved my bacon at least a dozen times.