Remote Backup Handling in DirectAdmin: FTP Transfers, Debugging, Custom ftp_upload.php, and Alternative Upload Methods

DirectAdmin currently supports remote backups via FTP/FTPS. This article explains how to configure remote FTP backups, manually test the ftp_upload.php script, understand all available environment variables, customize the upload process, convert ftp_upload.php to use curl or ncftpput, and troubleshoot common issues. It also covers how to override the default PHP-based uploader for advanced workflows.

FTP TransfersRemote BackupAlternative Upload Methods

~3 min read · Updated Feb 27, 2026

1. Remote Backup Options in DirectAdmin


As of now, DirectAdmin supports only one built‑in method for remote backups: transferring backup files to a remote FTP server. This is configured through:


Admin Level → Admin Backup/Transfer

Both FTP and FTPS are supported.


2. Manually Testing ftp_upload.php


If you need to debug FTP upload issues, you can manually run the ftp_upload.php script with environment variables.


2.1 Example Test Command


cd /usr/local/directadmin/scripts
ftp_port=21 \
ftp_local_file=/path/to/a/file.txt \
ftp_ip=1.2.3.4 \
ftp_username=fred \
ftp_password_esc_double_quote=fredspass \
ftp_path=/remote/path \
ftp_secure=ftps \
./ftp_upload.php

This will display any errors directly in the terminal. You should also check logs on the remote FTP server or run it in debug mode.


3. Environment Variables Available to ftp_upload.php


When customizing ftp_upload.php, it’s important to know which variables DirectAdmin passes to it. Below is an example output for a cron‑based FTP backup with ID=1:


action=backup
append_to_path=nothing
database_data_aware=yes
dayofmonth=5
dayofweek=*
email_data_aware=yes
ftp_ip=127.0.0.1
ftp_local_file=/home/tmp/admin/user.admin.testuser.tar.gz
ftp_local_path=/home/tmp/admin
ftp_password=pass"word
ftp_password_esc_double_quote=pass\"word
ftp_path=/admin_backups
ftp_port=21
ftp_remote_file=user.admin.testuser.tar.gz
ftp_username=admin
hour=5
id=1
minute=0
month=1
owner=admin
select0=testuser
type=admin
value=multiple
when=now
where=ftp

3.1 How to Generate This Variable Dump


cd /usr/local/directadmin/scripts/custom
cp /var/www/cgi-bin/printenv ftp_upload.php
echo "exit 1;" >> ftp_upload.php
chmod 755 ftp_upload.php
./ftp_upload.php

After running a backup, the script will output all environment variables. Delete it afterward and create your own custom version if needed.


4. Using Backup ID to Trigger Custom Behavior


You can customize behavior based on backup ID. For example, if you want backup ID 1 to upload via SCP instead of FTP:


if [ "$id" = "1" ]; then
   # scp upload code
   exit 0;
fi

Note: “When: Now” does not pass an ID. Running “Run Now” on an existing cron job does pass the ID.


5. Converting ftp_upload.php to Use curl


DirectAdmin’s default uploader uses PHP’s FTP functions. For debugging or advanced setups, you can replace it with curl.


5.1 Copy the Script


cp -rp /usr/local/directadmin/scripts/ftp_upload.php \
/usr/local/directadmin/scripts/custom/ftp_upload.php

5.2 Replace Contents with curl Version


/bin/sh
ETH=eth0
CURL=/usr/local/bin/curl

result=`$CURL --interface $ETH -T $ftp_local_file \
-u $ftp_username:$ftp_password_esc_double_quote \
ftp://$ftp_ip$ftp_path$ftp_remote_file 2>&1`

if grep -qi "curl: (67) Access denied: 530" <<< "$result"; then
    echo "FTP access denied. Check login details."
    exit 1
fi
if grep -qi "curl: (6) Couldn't resolve host" <<< "$result"; then
    echo "Host could not be resolved."
    exit 1
fi
if grep -qi "curl: (9) Uploaded unaligned file size" <<< "$result"; then
    echo "File upload failed. Check path."
    exit 1
fi
if grep -qi "curl: Can't open" <<< "$result"; then
    echo "Can't open $ftp_local_file"
    exit 1
fi

Ensure ftp_path ends with a trailing slash.


6. Converting to ncftpput


/bin/sh
/usr/bin/ncftpput -t 25 -m \
-u "$ftp_username" -p "$ftp_password_esc_double_quote" \
"$ftp_ip" "$ftp_path" "$ftp_local_file" 2>&1
RET=$?
exit $RET

7. Original PHP‑Based Upload Method


/usr/local/bin/php


This is the default method used by DirectAdmin.


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