Backup script not working correctly



Backup script not working correctly

Hello, maybe someone can look at this and see what Im missing,
Im using win2k8 to backup 7 Ubuntu servers using automation script But there is an issue since this is only for redundancy I don't have a lot of space, so out of 20 files on Ubuntu located in /home/backup/data/daily-2013-Mar-9-01-30-01-full.tbz I just want to pull the last one and copy it to my win2k8 backup.tbz file
So here is the script.

@echo off
rem WinSCP Server Automated Backup.
rem Created for ME

rem Settings.
rem Server Login
set session=webserver-CHEV

rem Folder Settings.
set server_folder=/home/backup/data/
set local_folder=E:\webserver-CHEV\

rem filename settings
rem auto_name will set the archive file to dd_mm_yyyy=h_m eg. 12_02_2010-17_58
set auto_name=0

rem manual_name is for when auto_name is set to 0.
set manual_name=backup.tbz

rem Path to winscp.
set winscp_path=C:\WinSCP\

rem Log File 1 or 0.
set logfile=1

rem ------------------------------------------------------------------

set hour=%time:~0,2%
if "%hour:~0,1%"==" " set hour=0%time:~1,1%
set file_auto=%date:~0,2%_%date:~3,2%_%date:~6,4%-%hour%_%time:~3,2%

IF "%auto_name%"=="0" (set filename=%manual_name%) else (set filename=%file_auto%)

echo option batch on > script.tmp
echo option confirm off >> script.tmp
echo option transfer binary >> script.tmp
echo open %session% >> script.tmp

rem this checks to see if source is root or a folder.
IF %server_folder%==/ (set source=/) else (set source=%server_folder:~1,-1%)
rem if folder not root add -c switch.
IF NOT %server_folder%==/ (set switch=-C / ) else (set switch=)
rem if folder root then add --exclude=/proc
IF %server_folder%==/ (set exclude=--exclude=/proc) else (set exclude=)

rem v swtich is required to stop
#echo call tar -cvzf %server_folder%%filename% %switch%%source% --exclude=%server_folder%%filename%

%exclude% >> script.tmp

echo get %server_folder%*.tbz>1D %local_folder%%filename% >> script.tmp

echo exit >> script.tmp

IF "%logfile%"=="1" (set filelog=/log=%local_folder%%filename%.txt) else (set filelog=)

rem Execute script
%winscp_path% /script=script.tmp %filelog%

rem Delete temporary script
del script.tmp

So I have get %server_folder%*.tbz>1D and it does not work, it pulls every file while Im only trying to load the file backed up from last night.

Any ideas welcomed,


Reply with quote


Site Admin
martin avatar
Prague, Czechia

Re: Backup script not working correctly

I believe the > before 1D is somehow interpreted by the Windows shell and never gets to the the script file.

I've tried
echo a b>c d > script.tmp

I get only 'a b d' in the script.tmp

But with
echo a "b>c" d > script.tmp

I get 'a "b>c" d'.

Reply with quote


You can post new topics in this forum