0

I have a script I am trying to run as a cron job. When typing the script in via a terminal there is no problem tho I am replacing the variables with the actual value.

#!/bin/bash
cd root/mqsql-backups
HOST='***.***.**.***'
USER='**********'
PASSWD='************'

ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd backup
put roofsmart_suitecrm_`date "+%m-%d-%Y"`.sql.gz
bye
EOT
sleep 12

It seems that when the time comes for the password variable to be called, that the password itself is not entered.

Using the commands below, I am able to connect to the ftp server no problem.

ftp user [USER] [Password]

The second question I had is regarding the file that I would like uploaded.

roofsmart_suitecrm_`date "+%m-%d-%Y"`.sql.gz

Is there an some way to get this to work through the ftp upload. I have done it this way, because I have another cron task that back ups and compresses a mqsql database daily, this script I would like to run 2 minutes later to upload this backup to an off site ftp server. While I have managed to make the sqldump cron job work(through much research), I just cant make heads or tails of this issue.

0

1 Answer 1

0

I never used it before, but just from reading the manual and some examples, I would try:

wput --ascii "roofsmart_suitecrm_`date "+%m-%d-%Y"`.sql.gz" "ftp://$USER:$PASSWORD@$HOST/backup/"

If you don't have wput yet on your computer, you can install it with:

sudo apt-get install wput
3
  • I have tried to read the manual and tweek the code some. Regardless of what I try, I continue to get the error "wput: not found", could this be due to the fact that it is an Ubuntu Server OS? Another thought is the fact that the ftp server is hosted with GoDaddy and the ftp user has a user name such as [email protected]. Could this potentially cause a problem with authentication?
    – Cole
    Jan 26, 2016 at 15:19
  • Ok so after trying it as a command in terminal rather than a script I can see I need to apt-get install wput. Will continue to work on this, and keep this topic updated
    – Cole
    Jan 26, 2016 at 16:21
  • Your script worked wonderfully. I ended up having to do this via terminal. Using notepad++ over ftp to edit the file was causing some weird errors, but after deleting recreating the file and using nano to write the script all went well. Thank You Very Much David!
    – Cole
    Jan 26, 2016 at 18:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .