Topic "Compress a directory before put command."

Author Message
Evan Boyd

Guest


Hello,

I'm rather new to all of this but I was finally able to get my game server to auto backup with windows scheduled tasks and WinSCP however, the transfer takes longer than I'd like because of all of the individual files in the directory i'm backing up each night. Is there a way I can compress this prior to it being uploaded to my FTP?

Here is my current Script/Bat

Script
Code:

option batch abort
option confirm off
open backups
put "C:\steamcmd\rust\backup\0\TheRustySpittoon_Live\" "/TheRustySpittoon_Live/Backup-%STAMP%"
exit


Bat
Code:

@echo off
 
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set LDT=%%j
set STAMP=%LDT:~0,4%-%LDT:~4,2%-%LDT:~6,2% %LDT:~8,2%-%LDT:~10,2%-%LDT:~12,2%
 
winscp.com /script=backup_script.txt


I literally have tried everything, I can't get it to even begin to zip a folder the console just instantly closes, with nothing. Any help would be greatly appreciated.

In advanced, thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24538
Location: Prague, Czechia
Just use any command-line utility from the batch-file to archive the C:\steamcmd\rust\backup\0\TheRustySpittoon_Live\ before running the WinSCP. Then use WinSCP to upload the archive. This has nothing to do with WinSCP.
Evan Boyd

Guest


What has nothing to do with WinSCP, the zipping a folder? Just to make sure I understand you correctly, you suggest having the bat file itself zip the directory, and not the WinSCP script?

What I'm trying to achieve is

Zip the directory

Upload that zip to my ftp

Delete local zip

Exit

This cannot be done with WinSCP?

Sorry, I'm just trying to fully understand...
Evan Boyd

Guest


prikryl wrote:
Just use any command-line utility from the batch-file to archive the C:\steamcmd\rust\backup\0\TheRustySpittoon_Live\ before running the WinSCP. Then use WinSCP to upload the archive. This has nothing to do with WinSCP.


Okay so I've been at this forever and I finally figured it out! I was able to call 7-zip, compress the folder I wanted, generate a temp script on the fly to upload to FTP and it even cleans everything up after.

I'm posting this just in-case anyone in the future needs to do what I needed to.

run.bat
Code:

set FileDate=%date:~10,4%_%date:~4,2%_%date:~7,2%
set BackupFile=C:\winscp\Backup_%FileDate%.7z

"C:\Program Files\7-Zip\7z.exe" a -r %BackupFile% C:\steamcmd\rust\server\TheRustySpittoon_Live

rem Generate temporary script to upload %BackupFile%
echo option batch on > script.tmp
echo option confirm off >> script.tmp
echo open backups >> script.tmp
echo put %BackupFile% "/TheRustySpittoon_Live/" >> script.tmp
echo exit >> script.tmp

rem Execute script
"C:\winscp\winscp.com" /script=script.tmp

rem Delete temporary script
del script.tmp
del Backup_%FileDate%.7z
Advertisements

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!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License