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

Related Articles

Email Client Configuration & Dovecot Quota/Monitoring Guide for DirectAdmin Users

This guide explains how to configure popular email clients (iPhone Mail, Thunderbird, Gmail POP/SMTP), enable Dovecot LMTP quota warnings, and check the last login time for all email accounts on a DirectAdmin server. It includes step by step instructions, recommended IMAP/SMTP settings, and useful administrative scripts.

Continue

Troubleshooting Dovecot in DirectAdmin – Fixing IMAP Errors, Authentication Issues, and SSL Certificate Checks

Dovecot is the IMAP/POP3 server used by DirectAdmin. Sometimes users encounter errors such as “Connection dropped by IMAP server” or “unknown user” during authentication. This guide explains how to fix corrupted Dovecot indexes, understand authentication logs, hide unnecessary warnings, and manually inspect SSL certificates on IMAP ports 143 and 993.

Continue

DNS Troubleshooting in DirectAdmin – When named is Running but Domains Do Not Resolve

Sometimes the named (BIND) service runs normally, yet DNS queries fail or domains do not resolve from outside. This guide provides a complete troubleshooting workflow for checking named listeners, firewall rules, named.conf configuration, DNS propagation issues, subdomain problems, resolv.conf errors, and common Apache/Nginx misconfigurations.

Continue

Managing DNS Records in DirectAdmin – Complete Practical Guide for Administrators

DirectAdmin provides a powerful DNS management system that allows administrators to control TTL values, create SRV records, enable DNSSEC, manage subdomain delegation, automate TLSA records, and perform mass DNS updates. This guide explains all essential DNS operations in DirectAdmin with real-world examples and best practices.

Continue

DNS and Nameservers in DirectAdmin – Complete, Practical, and Professional Guide

DNS is the backbone of the internet, responsible for translating domain names into IP addresses. DirectAdmin allows you to create private nameservers (ns1/ns2), manage DNS zones, configure DNS clustering, use external DNS, and troubleshoot common issues. This guide provides a complete, clear, and practical explanation of DNS concepts and their implementation in DirectAdmin.

Continue

CustomBuild in DirectAdmin – Complete Guide to Installation, Updates, Configuration, and Advanced Customization

CustomBuild is DirectAdmin’s primary software management system. It installs, updates, configures, and rebuilds essential services such as Apache, Nginx, PHP, MariaDB/MySQL, Exim, Dovecot, FTP servers, and more. Because most components are compiled from source, CustomBuild offers exceptional flexibility, fast access to new versions, and optimized performance.

Continue