How to Convert ftp_download.php to Use ncftpgetc

DirectAdmin allows full customization of its FTP download and upload mechanisms. This article explains how to convert ftp_download.php to ncftpget, how to slow down backup operations to avoid flooding remote FTP servers, how to build a redundant backup server using automated restores or rsync, and how to add dates or checksums to backup filenames using a custom ftp_upload.php script.

ftp_download.phpDirectAdmin FTP BackupRedundant Backup Server

~3 min read • Updated Feb 27, 2026

1. Converting ftp_download.php to ncftpget


If you want to replace the PHP-based FTP downloader with ncftpget, create the following file:


/usr/local/directadmin/scripts/custom/ftp_download.php

Insert the following content:


/bin/sh

FTPGET=/usr/bin/ncftpget
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 "cd /usr/local/directadmin/scripts";
       echo "./ncftp.sh";
       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_esc_double_quote" >> $CFG

$FTPGET -C -f $CFG -V -t 25 -P $PORT "$ftp_ip" "$ftp_path/$ftp_remote_file" "$ftp_local_file" 2>&1
RET=$?

/bin/rm -f $CFG

exit $RET

Make it executable:


chmod 755 /usr/local/directadmin/scripts/custom/ftp_download.php

2. Slowing Down Backup Rate to Avoid Flooding Remote FTP


If many users are being backed up, the backup system may connect too quickly to the remote FTP server, causing rate limits or blocks. You can add a delay after each user backup.


Create the file:


/usr/local/directadmin/scripts/custom/user_backup_post.sh

Add:


#!/bin/sh
sleep 20
exit 0;

Make it executable:


chmod 755 /usr/local/directadmin/scripts/custom/user_backup_post.sh

This adds a 20‑second pause after each user’s tar.gz backup is created.


3. Building a Redundant Backup Server


DirectAdmin is designed as a single‑server system, but you can still build redundancy using two main approaches:


3.1 Method 1: Nightly Backup Transfer + Automated Restore


You can transfer nightly backups to another DirectAdmin server and automatically restore them via cron.


To generate the restore command:


  • Start a normal restore
  • Immediately run:

cat /usr/local/directadmin/data/task.queue

The output is what you add to cron to automate restores.


3.2 Method 2: Using rsync (Recommended)


This method:


  • Does not require a second DirectAdmin license
  • Uses far less bandwidth
  • Transfers only changed files

Be careful not to overwrite system files such as /etc/passwd, /etc/group, /etc/shadow.


4. Adding a Date to FTP Backup Filenames


By default, FTP backups do not include a date in the filename. You can modify ftp_upload.php to add a date stamp.


4.1 Create a Custom Copy


cd /usr/local/directadmin/scripts/custom
cp ../ftp_upload.php .
chmod 755 ./ftp_upload.php

4.2 Add Date to Filename


Add this line after the #!/bin/bash shebang:


ftp_remote_file="`echo $ftp_remote_file | awk -F. '{for (i=1; i

You can also include an MD5 checksum:


ftp_remote_file="`echo $ftp_remote_file | awk -F. '{for (i=1; i

Note: This does not work with backup_ftp_md5=1 and requires backup_ftp_upload_confirmation to be disabled.


Written & researched by Dr. Shahin Siami