Backing up User Accounts FTP / S3? (Newbie)

GregW

Verified User
Joined
Aug 6, 2019
Messages
44
Location
Australia
I need to set my User Account Backups to go to a non-local (not the same VM/VPS) storage. So either FTP or AWS S3 has been suggested to me.

I enter the same details in the schedule where section but on submit schedule now, it gives the error message Failed to connect ... FTP information invalid.

So I try and use the same credentials using filezilla on my desktop PC and it connects fine.

How do I fix this so server to FTP will work?

Is AWS S3 a better option? What is the correct way to set that up?

I found this - https://github.com/powerkernel/directadmin-s3-backup, but it is very old so was not sure it was good to use.

Or do I have other options?

Cheers
 
Last edited:
I would say the problem is that CSF firewall do not allow connection to Passive FTP Ports of your Remote FTP server and you need to allow/whitelist those Ports in CSF firewall in /etc/csf/csf.conf file for "TCP_OUT" option there. And then restart CSF with such command:
Code:
csf -ra
If you do not know the range of Passive Ports of Remote FTP server, you can try running this command:

- for Debian/Ubuntu:
Code:
grep "UID=65534" /var/log/syslog | grep REAL_IP_of_REMOTE_FTP_SERVER | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c
- for RHEL based OSs:
Code:
grep "UID=65534" /var/log/messages | grep REAL_IP_of_REMOTE_FTP_SERVER | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c
 
FileZilla succeeding from your desktop only proves the credentials work from that machine/IP. DirectAdmin connects from the server's public IP and also needs the passive data connection.

Before changing CSF blindly, watch the remote FTP server log while clicking Run Now. If no login reaches it, check DNS/routing, outbound TCP 21 and any source-IP allowlist. If login succeeds but LIST/STOR stalls, the passive port range/firewall is the likely issue. A 530 response points more towards credentials, source-IP policy, or an FTP/FTPS mode mismatch. Also confirm the remote directory already exists and is writable.

DirectAdmin's current documentation says the only built-in remote destination is FTP, with FTPS available; S3 is not native. It also documents a manual ftp_upload.php test for seeing the real error. Use a small temporary file and do not paste credentials/output publicly:


I would first make FTPS work from the DA host, then run an actual restore test. A backup is only proven once restore succeeds.
 
Thanks all

I get a successful result via the ftp command to check if it can connect and upload ok, which it does (some edits to not use IP and domain)

root@server:~# ftp dabackups.webhost.com
Connected to dabackups.webhost.com.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 05:56. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (dabackups.webhost.com:root): admin_backups
331 User admin_backups OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.

Then

root@server:/usr/local/directadmin/scripts# ftp_port=21 ftp_local_file=/home/admin/dabackups/user.admin.viewwebs.tar.zst ftp_ip=155.xxx.xxx.77 ftp_username=dabackups ftp_password_esc_double_quote=oxxjxxxxxxixxK ftp_path=/home/dabackups.webhost.com ftp_secure=ftps ./ftp_upload.php

However when I try to do this in DA account backups I get

using port 21 and Secure FTP selected

/usr/bin/curl returned error code 9
curl: (9) Server denied you to change to the given directory
FTP information invalid.

Using the same but with port 22, after about 1 minute ...

/usr/bin/curl returned error code 28
curl: (28) Failed to connect to 155.xxx.xxx.77 port 22 after 136339 ms: Couldn't connect to server
FTP information invalid.

Using port 21 not selecting Secure FTP

/usr/bin/curl returned error code 7
curl: (7) Failed to connect to 155.xxx.xxx.77 port 21 after 113 ms: Couldn't connect to server
FTP information invalid.

Using port 22 not selecting Secure FTP

/usr/bin/curl returned error code 28
curl: (28) Failed to connect to 155.xxx.xxx.77 port 22 after 134546 ms: Couldn't connect to server
FTP information invalid.

I am working through the suggestions above.

The remote server is using CyberPanel, so I am assuming this will make a difference?

Thanks
 
Last edited:
When I look at the FTP logs on my CyberPanel server, i see

Nov 24 06:46:21 backups pure-ftpd: ([email protected]) [INFO] New connection from 104.XXX.XXX.147
Nov 24 06:46:21 backups pure-ftpd: ([email protected]) [INFO] TLS: Enabled TLSv1.3 with TLS_AES_256_GCM_SHA384, 256 secret bits cipher
Nov 24 06:46:21 backups pure-ftpd: ([email protected]) [INFO] admin_backups is now logged in
Nov 24 06:46:21 backups pure-ftpd: ([email protected]) [INFO] Logout.

So it looks like it logs in ok, but then logouts? denied?
 
@GregW What about Passive FTP Ports I asked above ?
Code:
grep "UID=65534" /var/log/syslog | grep 155.XXX.XXX.77 | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c
or
Code:
grep "UID=65534" /var/log/messages | grep 155.XXX.XXX.77 | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c

in case if 155.XXX.XXX.77 IP is the IP of your Remote FTP server.
Any useful results there ?

Also you CANNOT use SFTP there (22 Port), because it does NOT work. Only FTP or FTPS can be used for that type of backups.
 
Code:
grep "UID=65534" /var/log/syslog | grep 155.XXX.XXX.77 | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c

Result
1 40111
1 40113
3 40115
1 40118
2 40120
1 40123
1 40124
2 40125
1 40128
2 40130
2 40134
3 40135
2 40136
1 40137
1 40138
1 40143
1 40144
2 40146
1 40148
1 40152
1 40155
1 40157
2 40158
1 40160
1 40162
1 40165
1 40166
1 40170
2 40173
1 40183
1 40187
1 40188
1 40191
1 40192
1 40193
1 40195
1 40197
2 40201
1 40202
1 40203
1 40207


or
Code:
grep "UID=65534" /var/log/messages | grep 155.XXX.XXX.77 | awk -F'DPT=' '{print $2}' | awk '{print $1}' | sort | uniq -c

Result
grep: /var/log/messages: No such file or directory


Any useful results there ?

Do those results help at all?

Also you CANNOT use SFTP there (22 Port), because it does NOT work. Only FTP or FTPS can be used for that type of backups.

Ok thanks
 
Yes, it can be useful and it says that your OS is either Ubuntu or Debian (because /var/log/messages file does not exist there) I recommend adding the range of such Ports:

40100:40300

into /etc/csf/csf.conf file for "TCP_OUT" option.
The result will be similar to this:
Code:
[root@server2 ~]# grep ^TCP_OUT /etc/csf/csf.conf
TCP_OUT = "20,21,22,25,2525,53,853,80,110,113,143,443,465,587,993,995,2222,40100:40300"
[root@server2 ~]#
and then restart CSF with this command:
Code:
csf -ra
After that try to configure remote FTP backups via DA Panel and check if it works OK
 
Yes, it can be useful and it says that your OS is either Ubuntu or Debian (because /var/log/messages file does not exist there) I recommend adding the range of such Ports:

40100:40300

into /etc/csf/csf.conf file for "TCP_OUT" option.

Woohoo, it works, you are a legend and if I could, I'd buy you a drink of your choice.
 
Ok, my next question, is there a way I can get it to not timeout during ftp transfer for large backup files as it does stop the transfers completing.

I am getting these errors now as they contain large file transfers, with some up to 6GBs each

ftp_upload.php exit code: 55
ftp_upload.php output: curl: (55) Send failure: Broken pipe
curl return code: 55

or

ftp_upload.php exit code: 55
ftp_upload.php output: curl: (55) Send failure: Connection reset by peer
curl return code: 55
 
Last edited:
Back
Top