I'm trying to get WinSCP to back up a file every hour and then put a time stamp on the file. I know how to do everything except the timestamp part.
(I want the file to be filename -> filenameMMDDHH)
Current script:
[code]
option batch on
option confirm off
open user:password@host (edited out)
cd ..
cd ..
cd media
cd MC
option transfer binary
get server_level.dat server_level.dat (I want date here)
close
exit
[/code]
This is for my Minecraft server, my current system gets the file and then uploads it to Waula, but Walua doesn't keep any more than 10 copies of the file with previous versions and I'd like more than that, so instead it will upload every timestamped file to the server.
[editline]09:17PM[/editline]
Here's some documentation I barely understand.
[url]http://winscp.net/eng/docs/[/url]
No help? :( All I need is a way for my Windows 7 PC to get the file from my Linux server, and name the file server_level[timestamp].dat, every hour, I don't mind if I need another program.
Chuck a wget and a rename together
I know how to rename and everything, but I don't know how to make it find the time and rename it to the time.
Try
[code]
get server_level.dat server_level.dat 'time /T' 'date /T'
[/code]
That should work.
[QUOTE=t0rento;18999365]Try
[code]
get server_level.dat server_level.dat 'time /T' 'date /T'
[/code]
That should work.[/QUOTE]
That didn't seem to do anything differently.
[QUOTE=Shadaez;19008324]That didn't seem to do anything differently.[/QUOTE]
Hmm, maybe I misunderstood the syntax. Try this (I'm assuming that it uses Batch style scripting)
[code]
SET D=date /T
SET T=time /T
get server_level.dat server_level%D%%T%.dat
[/code]
[b]Edit:[/b]
Just read the doc's a bit more and I don't think the above approach would work. You might need to have a separate batch file to do something like this:
[b]Backup.bat[/b]
[code]
@echo off
SET D=date /T
SET T=time /T
winscp.com /script=yourscript.txt /parameter %D%%T%
[/code]
Then in your script
[b]yourscript.txt[/b]
[code]
option batch on
option confirm off
open user:password@host (edited out)
cd ..
cd ..
cd media
cd MC
option transfer binary
get server_level.dat server_level%1%.dat (I want date here)
close
exit
[/code]
Note: I didn't test this, but what it should do is cause the batch file to pass the Date and Time as parameter 1 to the WinSCP script, then embed that as the new name.
That didn't work; but I think I see what you're trying to do and I'm troubleshooting on my own, you're welcome to help some more though.
[editline]06:47AM[/editline]
All it's doing is coming out as "server_level1%251%25.dat" It's just displaying the 1%'s in the file name.
[editline]06:53AM[/editline]
I really appreciate your help. If there's even a way to add a number at the end that changes every backup, that would be good enough (server_level1.dat, server_level2.dat, etc).
I've decided to do away with winSCP and to attempt to make my own program! It will be a great test of what I've been learning lately. :3
Sorry, you need to Log In to post a reply to this thread.