Backup local directory to FTP server with adding actual "date-time" to remote directory name

Advertisement

bogomil
Joined:
Posts:
3

Backup local directory to FTP server with adding actual "date-time" to remote directory name

Hello everybody,
I have to do automated daily backup of local "data"-directory of a cash register system to a FTP server at a specific time (06:00 a.m).
Nn the FTP server, there should be added actual "date-time" to remote directory name. e.g. data >>> 2016-11-15_0139_data
Can you provide me with a sample script, where similar problems have been solved before or give me some hints – many thanks in advance.

Reply with quote

Advertisement

Wt
Guest

The opposite way

I need the same thing but only in the opposite direction. So, I need to schedule my PC to connect to remote FTP, collect all the files & folders there and copy those to my HDD at certain interval. The most important thing is that every time it collect the data, it create new containing folder with date&time stamp in folder name on a local drive so I could have multiple backups without overwriting the old ones.

Thanks in advance

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,367
Location:
Prague, Czechia

Re: The opposite way

The solution is the same:
get /remote/path/* C:\local\path\data\%TIMESTAMP#yyyy-mm-dd%
Except that WinSCP cannot create the target local directory for you. You have to create it before starting WinSCP.
E.g. from a wrapper batch file or PowerShell script.

You can still use WinSCP to generate the directory name for you:
https://winscp.net/eng/docs/script_formatting_timestamp_batch_file

rem Create new local directory
set TIMESTAMP_FORMAT=yyyy-mm-dd
for /F "tokens=* USEBACKQ" %%F in (`winscp.com /command "echo %%TIMESTAMP#%TIMESTAMP_FORMAT%%%" "exit"`) do set TIMESTAMP=%%F
mkdir C:\local\path\data\%TIMESTAMP%
 
rem Run WinSCP to download files to the newly created directory
winscp.com ...

Reply with quote

bogomil
Joined:
Posts:
3

Re: backup local directory to ftp Server with adding actual "date-Time" to remote directory-Name

Many thanks for help – I tested script – but remote folder was not resolved with "time-date-stamp" – remote folder appears as follows:
/remote/path/%TIMESTAMP#yyyy-mm-dd%_data
What can I do? – thank for help in advance ...

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum