Advertisement
MetaMSP

archiveAndUploadLTLogsToFTP

Jul 26th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.38 KB | None | 0 0
  1. @ECHO OFF
  2. set sourcePath=C:\Program Files\Labtech\Logs
  3. set destPath=%WINDIR%\Temp
  4. set destFilePrefix=LTLogsForAcronis_
  5. REM FTP Settings
  6. set uploadToFTP=YES
  7. set ftpServer=myFTPServer
  8. set ftpUser=myUsername
  9. set ftpPass=<password>
  10. set ftpPath=Log Snapshots/
  11. REM code below this line
  12. set hh=%time:~-11,2%
  13. set /a hh=%hh%+100
  14. set hh=%hh:~1%
  15. set stampDateTime=%date:~10,4%%date:~4,2%%date:~7,2%T%hh%%time:~3,2%%time:~6,2%
  16. set destFilename=%destFilePrefix%%stampDateTime%.zip
  17. IF EXIST "%destPath%\%destFilename%" EXIT /B 1
  18. powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem';[IO.Compression.ZipFile]::CreateFromDirectory('%sourcePath%', '%destPath%\%destFilename%'); }"
  19. IF NOT EXIST "%destPath%\%destFilename%" EXIT /B 1
  20. IF NOT DEFINED uploadToFTP EXIT /B
  21. DEL /Q "%destPath%\curl.*"
  22. powershell.exe -nologo -noprofile -command "& { (New-Object Net.WebClient).DownloadFile('http://www.paehl.com/open_source/?download=curl_761_0.zip','%destPath%\curl.zip');(new-object -com shell.application).namespace('%destPath%').CopyHere((new-object -com shell.application).namespace('%destPath%\curl.zip').Items(),16); }"
  23. IF NOT EXIST "%destPath%\curl.exe" EXIT /B 1
  24. "%destPath%\curl.exe" -T "%destPath%\%destFilename%" "ftp://%ftpServer%/%ftpPath%%stampDateTime%.zip" --user %ftpUser%:%ftpPass%
  25. DEL /Q "%destPath%\curl.*"
  26. DEL /Q "%destPath%\%destFilename%"
  27. EXIT /B
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement