Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

jpwanabe

Thanks for the help man, but I just cant get this to work. Getting errors that I can't figure out what they mean or how to fix em. I think I'm going to just give up at this point. Been trying for a while. I just cant seem to get power shell.
martin

I'm no PowerShell expert, and there are probably many ways. But for example this will do:
$foldersSet = @( 
    @{ remote = "folder1/backups"; local = "F:\Server_backups\ATM6" },
    @{ remote = "folder2/backups"; local = "F:\Server_backups\RLCRAFT" },
    @{ remote = "folder3/backups"; local = "F:\Server_backups\POKE" },
    @{ remote = "folder4/backups"; local = "F:\Server_backups\BMF" }
)
 
foreach ($folders in $foldersSet)
{
    $remotePath = $folders.remote
    $localPath = $folders.local
 
    Write-Host "$remotePath => $localPath"
 
    $directoryInfo = $session.ListDirectory($remotePath)
    # ... and the rest of the code up to $session.GetFileToDirectory
}
jpwanabe

This is what my script is atm
"F:\Program Files (x86)\WinSCP\WinSCP.exe" ^
  /log="F:\desktop\MC server\!auto\backup.log" /ini=nul ^
  /command ^
    "open ftp://user:pass@ip/ -rawsettings ProxyPort=0" ^
      "get -latest folder1/backups/*.zip F:\Server_backups\ATM6\*" ^
      "get -latest folder2/backups/*.zip F:\Server_backups\RLCRAFT\*" ^
      "get -latest folder3/backups/*.zip F:\Server_backups\POKE\*" ^
      "get -latest folder4/backups/*.zip F:\Server_backups\BMF\*" ^
      "exit"
martin

So how are you doing it currently with the script?

Anyway, see how some examples on this site use PowerShell script command-line argument to get all the settings needed for the code. For example:
https://winscp.net/eng/docs/extension_archive_and_download
Note the $sessionUrl, $remotePath and $localPath parameters. And the use of $sessionUrl with SessionOptions.ParseUrl.
jpwanabe

I've been trying to get this working but I do have a question. How would I set multiple remote and local locations in the script for powershell? I have never messed with it before now. I was doing it all from .bat files. I can't seem to figure it out without multiple scripts. Sorry for the newbie question.
jpwanabe

Getting SECOND newest file?

So I am running a few game servers for multiple games and am running into an issue with automatic backup of some of the servers. I have a script that downloads the latest zip file once a day at 2am. The issue is with the larger servers that take a long time to make that zip file. If the file is in the process of still being zipped and the script runs to download that zip, the whole process stalls out. If there was a way to download the second newest file this issue would not be a problem. I can't seem to find a way to do this after searching for a few days. Any help would be appreciated.

One line of current script for reference
"get -latest IP_PORT/backups/*.zip F:\Server_backups\ATM6\*" ^