Backup Scipt not working properly

Advertisement

centerstage
Guest

Backup Scipt not working properly

Hi!

I want to backup the complete Linux server to my local PC. Content should be compressed and then downloaded. The current script creates tar.gz files but they are empty, so there are no files in there. No error messages occur in console.

Can anyone help me with this issue? Thanks! Toby


SCRIPT (run.bat):

@echo off
rem WinSCP Server Automated Backup.

rem Settings.
rem Server Login
set session=root

rem Folder Settings.
set server_folder=/
set local_folder=H:\Server_Backup\Archives\

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=1

rem manual_name is for when auto_name is set to 0.
set manual_name=server_backup

rem Path to winscp.
set winscp_path="C:\Program Files (x86)\WinSCP\WinSCP.exe"

rem Log File 1 or 0.
set logfile=1

rem DO NOT EDIT BELOW HERE
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 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 switch is required to stop
echo call tar -cvzf %server_folder%%filename%.tar.gz %switch%%source% --exclude=%server_folder%%filename%.tar.gz %exclude% >> script.tmp

echo get %server_folder%%filename%.tar.gz %local_folder%%filename%.tar.gz >> script.tmp
echo rm %server_folder%%filename%.tar.gz >> 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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Backup Scipt not working properly

Have you checked the contents of the generated script.tmp, if the tar command has correct syntax?

Reply with quote

Guest

Changed:

----------------------
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%
----------------------

TO

----------------------
set file_auto=%date:~8,12%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%
----------------------

-> German Region Settings

Now it works :-)

Reply with quote

Advertisement

You can post new topics in this forum