Topic "Backup Scipt not working properly"

Author Message



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

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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 22362
Location: Prague, Czech republic
Have you checked the contents of the generated script.tmp, if the tar command has correct syntax?
Martin Prikryl


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%


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

-> German Region Settings

Now it works Smile

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License