I have a script that was provided for me so i can download database backups that are generated. Script works fine but i'd like to change the location they are downloaded to, or move them after they are downloaded

Currently they are downloaded into the folder with the bat file. I'd like them in
App Folder -> mysql

This is the two files that deal with the downloading

The file i run. downloads.bat

ftp  -i -s:ftp.txt

and this is ftp.txt

open midnighttempest.com
user
pass
cd backups/
binary
mget archives/
mdelete archives/
quit

    There may be a better way, but the first thing that comes to my mind is:

    cd c:\path\to\desired\directory
    ftp  -i -s:ftp.txt
    

    I believe you could also do it in the FTP script via the "lcd" command, if memory serves me correctly.

      so if i had it as

      cd C:\Users\Desbrina\Documents\Web Sites\Database Backups\mysql
      ftp  -i -s:ftp.txt

      it should work? I'm not at home at the moment so i can't test it

        ok, itested what you gave me, and it ends up looking for the ftp.txt file within the mysql folder, so its looking for the file in the wrong place. lcd doesn't seem to work, its still downloading to the main folder not mysql

        this is what i get in command promp

        C:\Users\Desbrina\Documents\Web Sites\Database Backups>ftp  -i -s:ftp.txt
        ftp> open midnighttempest.com
        Connected to midnighttempest.com.
        220 ProFTPD 1.3.1 Server (DreamHost FTP) [66.33.212.183]
        User (midnighttempest.com:(none)):
        331 Password required for carebearcez
        
        230 User carebearcez logged in
        ftp> cd backups/
        250 CWD command successful
        ftp> binary
        200 Type set to I
        ftp> lcd c:\Users\Desbrina\Documents\Web Sites\Database Backups\mysql\
        lcd local directory.
        ftp> mget archives/
        200 Type set to I
        200 PORT command successful
        150 Opening BINARY mode data connection for archives/mysql-26-10-08-17.tar.gz (2
        287978 bytes)

          I'm wondering if the directory path needs to be quoted since it has spaces in it? (Sorry, it's been a long time since I wrote any Windows batch files, so I'm forced to be a bit vague here as I'm too lazy to do the research. 😉 )

            i get a slightly different message with quotes but it still doesn't work

            C:\Users\Desbrina\Documents\Web Sites\Database Backups>ftp  -i -s:ftp.txt
            ftp> open midnighttempest.com
            Connected to midnighttempest.com.
            220 ProFTPD 1.3.1 Server (DreamHost FTP) [66.33.212.183]
            User (midnighttempest.com:(none)):
            331 Password required for carebearcez
            
            230 User carebearcez logged in
            ftp> cd backups/
            250 CWD command successful
            ftp> binary
            200 Type set to I
            ftp> lcd "c:\Users\Desbrina\Documents\Web Sites\Database Backups\mysql\"
            \Users\Desbrina\Documents\Web Sites\Database Backups\mysql\: F
            ftp> mget archives/
            200 Type set to I
            200 PORT command successful
            150 Opening BINARY mode data connection for archives/mysql-27-10-08-15.tar.gz (2
            290973 bytes)

              I don't suppose you could just do it with a PHP script? 😉

                how easy would it be and would it have to be on my site? i'd only want it from from my pc, or have some way of stopping normal users from accessing the file and downloading the backups

                  As long as you have PHP installed on your PC (see WAMP and XAMPP), you could run it there. There can be a few environment differences between running it via the command line (the CLI) versus via the web server, but I doubt there'd be any issues with the type of script we're looking at here. You could even wrap it up in a batch file if you wanted.

                  c:\wamp\bin\php\bin\php  c:\path\to\ftp_script.php
                  

                    ok, so what would i have to look at in order to write a script to do this. i have XAMPP installed on my PC already, though i don't tend to have it running

                    Edit: After a quick look at the PHP site it appears as though i can use ftp_get to do what i want. The only question is the example they gave is for a specific file whereas i want to download all that are in a directory. And how do i then delete the file once its successfully downloaded?

                      Write a Reply...