Whenever one would try to use the FTP backup method to store the backup on a FTP server that is sitting behind a firewall/router, which is not capable of providing sufficient FTP transfer support, the file transfer would fail. In that case FTP's passive mode would not work, even though a connection using the FTP control port 21 could be established. In the described setup it would be necessary to disable passive mode and use active mode.
From the command line this would be accomplished by just typing 'passive' since this command is a toggle for active/passive mode.
[root@pbx asterisk]# ftp backup.some-dude.com
Connected to backup.some-dude.com.
220-FileZilla Server version 0.9.37 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/filezilla/
502 GSSAPI authentication not implemented
504 Auth type not supported
KERBEROS_V4 rejected as an authentication type
Name (backup.some-dude.com:root): pbx
331 Password required for pbx
Password:
230 Logged on
Remote system type is UNIX.
ftp> passive
Passive mode off.
ftp> ls
200 Port command successful
150 Opening data channel for directory list.
-rw-r--r-- 1 ftp ftp 22200952 Aug 09 21:16 20110809.21.15.42.tar.gz
drwxr-xr-x 1 ftp ftp 0 Aug 09 20:02 test
226 Transfer OK
ftp>
Unfortunately I was not able to find any configuration switch within FreePBX that would allow me to choose from active or passive mode.
I fixed this limitation by adding the toggle to the FTP login and transfer sequence.
/var/www/html/admin/modules/backup/bin/ampbackup.php:
251 if( $opts['ftpuser'] && $opts['ftppass'] && $opts['ftphost']){
252 $fh = fopen($opts['ftpfile'], 'w');
253 $data = 'user ' . $opts['ftpuser'] . ' ' . $opts['ftppass'] . " \n";
254 $data .= "passive\n";
255 $data .= "binary\n";
256 if($opts['ftpdir'] != ''){
257 $data .= "cd ${opts['ftpdir']} \n";
258 }
modification on line 254
From my point of view this is a very critical limitation since the absence of the abilit to switch between these two operational modes can make this module useless for many people that depend on active mode.
This feature could be implemented by including an 'active mode' checkbox into the backup-/restore gui. Some if-clause that is checking on the checkbox would need to be added to the workaround described above.