Backup to FTP does not work

Performing a backup in FreePBX 10.13.66-5 works fine when I use only local storage. However when I use FTP server, it does not work. Here is a copy of the backup.log from /tmp

Parameters used for ftp:

hostname: (ip of ftp server, same internal network as pbx)
port: 21
username/password (same as account setup on ftp site…confirmed by doing ftp from shell on pbx)
path: /files/FreePBX. (r/w access given to account)
transfer mode: Passive

Log file:

September 17, 2015, 10:58 pm - Backup Lock acquired!
September 17, 2015, 10:58 pm - Running pre-backup hooks...
September 17, 2015, 10:58 pm - data: Backup Lock acquired!
September 17, 2015, 10:58 pm - data: Running pre-backup hooks...
September 17, 2015, 10:58 pm - Adding items...
September 17, 2015, 10:58 pm - data: Adding items...
September 17, 2015, 10:59 pm - Bulding manifest...
September 17, 2015, 10:59 pm - data: Bulding manifest...
September 17, 2015, 10:59 pm - Creating backup...
September 17, 2015, 10:59 pm - data: Creating backup...
September 17, 2015, 11:00 pm - Storing backup...
September 17, 2015, 11:00 pm - data: Storing backup...
September 17, 2015, 11:00 pm - data: Whoops\Exception\ErrorException: ftp_chdir(): Failed to change directory. in file /var/www/html/admin/modules/backup/functions.inc/class.backup.php on line 338
September 17, 2015, 11:00 pm - data: Stack trace:
September 17, 2015, 11:00 pm - data:   1. Whoops\Exception\ErrorException->() /var/www/html/admin/modules/backup/functions.inc/class.backup.php:388
September 17, 2015, 11:00 pm - data:   2. Whoops\Run->handleError() :0
September 17, 2015, 11:00 pm - data:   3. ftp_chdir() /var/www/html/admin/modules/backup/functions.inc/class.backup.php:388
September 17, 2015, 11:00 pm - data:   4. FreePBX\modules\Backup\Backup->store_backup() /var/www/html/admin/modules/backup/bin/backup.php:144
September 17, 2015, 11:00 pm - data: END

Update: I can backup to the Local Storage (local) location, as well as to my Amazon S3 bucket. Still can not backup to my FTP server. Just a repeat, I can log on to the FTP server from a terminal on the pbx machine, as well as a windows machine. All of these devices are on the same LAN, same subnet. However, FreePBX throws the Whoops exception in the above log file. Yes, I have check the path. The path I am trying to backup to on the ftp server is: /BAKER-2GB/FreePBX

I have tried /BAKER-2B/FreePBX and /BAKER-2GB/FreePBX/ (last slash added), but both seem to throw this error, seemingly related to “Failure to change directory”.

If anyone has any ideas, I would appreciate it.

Thanks.

I just upgraded to version 13 and the problem is still the same. Was this solved or do we still have to create the target directory before doing the backup?

As are most things this is solved in edge.

Guessing, but I’d be curious to find out if you have all of the required directories created? Since it’s trying to chdir and failing, the destination its trying to hit is probably not there.

in theory the directories are auto created…

Yeah, but there are enough vagarious systems out there that it could be an issue - Windows is notorious for munging directory names and silently telling you that everything is OK until you actually try to use it.

Personally, I’d FTP the backup to the server the first time with the credentials you want to use, and then see of the backup works after that.

It’s really the only suggestion I have - I’m with @jfinstrom that the directories should be getting auto-created, but for some reason, the directories are borked when you try to use them.

What happens (in the code)

  • change to foo
  • if error try to create foo
  • change to foo
  • if error alert the user that stuff is broke…

I actually went through last week and rewrote a bunch of this using an FTP library to allow us to better handle system diversity and errors.

One problem after I did the rewrite was some issues with iis. The library has a windows specific handler.

In the latest release we,

  • setup the connection
  • ask hey what type of system are you.
  • If windows implement the windows file system handler.