Using Curl with the FTPS Reseller Backup Restore instead of PHP or NCFTP

Stevio

Verified User
Joined
Mar 7, 2016
Messages
9
For some reason the FTPS Reseller Backup Restore didn't work so I made a custom script to use Curl based on the ftp_upload script.

Based on:


It works for me. Hope it can be of any help to someone else. Cheers

Steps:

1. Create the file: /usr/local/directadmin/scripts/custom/ftp_download.php
2. chmod 755 /usr/local/directadmin/scripts/custom/ftp_download.ftp
3. nano /usr/local/directadmin/scripts/custom/ftp_download.ftp
4. Place the following code into the file:

Code:
#!/bin/sh

CURL=/usr/local/bin/curl
TOUCH=/bin/touch
PORT=${ftp_port}

if [ ! -e $TOUCH ] && [ -e /usr/bin/touch ]; then
       TOUCH=/usr/bin/touch
fi

if [ ! -e $FTPGET ]; then
       echo "";
       echo "*** Backup not downloaded ***";
       echo "Please install $FTPGET by running:";
       echo "";
       echo "";
       exit 10;
fi

CFG=${ftp_local_file}.cfg
/bin/rm -f $CFG
$TOUCH $CFG
/bin/chmod 600 $CFG
/bin/echo "host $ftp_ip" >> $CFG
/bin/echo "user $ftp_username" >> $CFG
/bin/echo "pass $ftp_password" >> $CFG

result=`$CURL --ssl -u $ftp_username:$ftp_password ftp://$ftp_ip:$ftp_port/$ftp_path/$ftp_remote_file -o $ftp_local_file 2>&1`

/bin/rm -f $CFG
 
Update: In case it doesn't work for you then 9 out of 10 times it's caused by an self signed certificate.
To verify this or if you don't care and want to ignore this change the Curl command with the insecure -k flag:

Code:
result=`$CURL -k --ssl -u $ftp_username:$ftp_password ftp://$ftp_ip:$ftp_port/$ftp_path/$ftp_remote_file -o $ftp_local_file 2>&1
 
Back
Top