Find the answer to your Linux question:
Results 1 to 3 of 3
I am no expert when it comes to writing scripts and so on. So I wonder if somebody here could give me some help please. We have a dedicated Linux ...
  1. #1
    Just Joined!
    Join Date
    Feb 2006
    Posts
    2

    Automated FTP help

    I am no expert when it comes to writing scripts and so on. So I wonder if somebody here could give me some help please.

    We have a dedicated Linux server running a number of websites. The admin panel is called cpanel which I'm sure many of you are familiar with. We use the backup facility on cpanel to backup our sites to FTP space at another location. The backup runs daily, weekly, and monthly automatically.

    One problem I discovered today is that the daily backup procedure overwrites the previous days backup. I wrongly assumed that the daily backup would not do this since the name of the tar file that gets created within the daily backup directory is named by date. It seems a bit silly really because what is the point in naming it by date if it's only going to be the previous days backup every time.

    So, since I know no way of changing this, I decided to set about writing a very simple script called by issuing the command ftp -inv <archive.txt at a telnet prompt from where my server is. It should be noted at this point, I don't have the option of creating a script on the FTP space itself. if I could then it would be easy.

    The archive.txt file contains the following:-

    open MyftpIP
    user myUsername MyPassword
    cp -r /cpbackup/daily/* /archive
    bye
    quit

    Of course I realised pretty quickly that cp doesn't work from ftp.

    So then I though maybe I could just use something like scp or rsync. The problem is (correct me if I'm wrong) is that using these commands will have the effect of first downloading the file from the remote to source and back again. And since we have to pay for bandwidth, it would be a waste of money and resource.

    So thinking some more, what I need is a kind of automated telnet. Because this is in effect what needs to happen.

    Anyway, it's over to you experts, as I have no idea how to achieve my aim which is basically to copy one directory to another on a remote FTP server, but without the script being on the FTP server. If that makes sense.

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Posts
    1,695
    Google "linux bash ftp script" => One of many hits

  3. #3
    Linux Engineer
    Join Date
    Nov 2004
    Location
    Ft. Polk, LA
    Posts
    796
    You might be interested in a wonderful tool called expect.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...