backdrop-contrib/backup_migrate

PHP 8: Error messages: RESTORE / SAVED BACKUPS when using FTP Destination

Closed this issue · 19 comments

Hello,

I know Backup & Migrate from Drupal 7 but have a problem here on a freshly installed Backdrop:

It works: create backups to the directories

Manual Backups Directory	private://backup_migrate/manual
Scheduled Backups Directory 	private://backup_migrate/scheduled

But when I click on the tab Restore this error appears:

Restoring will delete some or all of your data and cannot be undone.
Always test your backups on a non-production server!
ftp_systype(): Argument #1 ($ftp) must be of type FTP\Connection, null given 

And when I click on the tab Saved Backups this error appears:

ftp_systype(): Argument #1 ($ftp) must be of type FTP\Connection, null given

--

Backup and Migrate 1.x-1.0.21
Backdrop CMS 1.23.0
PHP 8.1.7
Firefox 107

Many greetings, Tikita

I'm using Backup and Migrate as well and don't see the error. Searching Drupal issue queue I found however a similar issue:

https://www.drupal.org/project/backup_migrate/issues/3305432

From what I read there, it seems to be an issue with PHP 8.

And one question: Is Backup and Migrate somehow configured to use a FTP connection?

Yes, I had set up another backup destination to an FTP server. If I remove this, then the error message no longer appears. Thanks for your hint!

But it's also a PHP problem: the PHP manual writes about ftp_systype that with version 8.1 "the ftp parameter expects an FTP\Connection instance now; previously, a resource was expected".

It would be great if Backup and Migrate would also work with PHP 8.1.

PR #85 provided and ready for testing/review.

Please test this with the current dev branch (or by patching the most recent release), which includes another FTP fix.

@tikita are you able to test this fix?

Reopening while people test this.

tikita commented

Hello, when I set up a backup destination to an FTP server, and when when I click on the tab Saved Backups then the error message still appears:

ftp_systype(): Argument #1 ($ftp) must be of type FTP\Connection, null given

Backup and Migrate 1.x-1.0.22
Backdrop CMS 1.25.1
PHP 8.1.15
Firefox 114.0.1

Tikita

@tikita thanks. Are you using the dev version of the module to test?

tikita commented

I look on https://backdropcms.org/node/182/releases-table and do not see a dev version.

The dev version is the 1.x-1.x branch. You can download it here:
Download ZIP

Can you please try this with that version and report back? Thanks.

tikita commented

I have uninstalled Backup and Migrate 1.x-1.0.22.

Then I installed backup_migrate-1.x-1.x.

The error message when I click on Saved Backups (see above) does not appear now.

But I get the message

FTP Error: Couldn't change into the var/www/vhosts/hosting******.*****.netcup.net directory

and this surprises me, because I know exactly the data of the external server and I always access it (e.g. with Filezilla).

backup-migrate-ftp-zugang

PS: I have also asked the provider (Netcup) for support, let's see what comes from there.

Thanks for testing! In path be sure to put the path where the files are from the point of view of the ftp logged in account, NOT the absolute path of the server. So, for example, if your files are in a folder my-files from the point of view of the logged in FTP user, the enter my-files. If the files are in the root from the point of view of the logged in FTP user, then enter ./

tikita commented

Thanks for pointing out that only a folder needs to be specified, but unfortunately no:

myfolder or
/myfolder or
myfolder/

or simply specify the base directory with

./

will always lead to the error message

FTP Error: Couldn't change into the myfolder directory
FTP Error: Couldn't write to ./mysite-2023-07-01T22-07-02.sitearchive.tar.gz when trying to save file on the ftp server.
Could not run backup because the file could not be saved to the destination.

Although this PR is included in 1.x-1.0.23, I'll leave this open to do some more testing. In my tests, this works, but I'll need to take a closer look at @tikita's comments.

tikita commented

Updated Backdrop CMS to version 1.26.0 today.

Regarding the unchanged installed backup_migrate-1.x-1.x. there was no new reaction except the already mentioned messages.

But I found another protocol note:

Warning: ftp_nlist(): Connection timed out in backdrop_ftp_file_list() (Zeile 306 von /hp/cw/ab/cc/www/myfolder/modules/backup_migrate-1.x-1.x/includes/destinations.ftp.inc).

@tikita, FTP is working for me in the latest version of Backup and Migrate (version 1-x.1.0.23). The configuration is a bit tricky with FTP in general. I'm pasting screenshots. Hopefully that will help you configure the destination correctly. If not, this may be a problem with your host.

First I created my FTP account. I use cPanel in my host to do this. IMPORTANT: notice that, while cPanel added a Directory to my account (that is, tenutoweb.com/myftp) that path is invisible to my ftp account once I'm logged in. See the Backdrop configuration below for this.

Screen Shot 2023-09-17 at 8 09 31 AM

Once I have that, I configure Backup and Migrate. I added a new FTP destination:

Screen Shot 2023-09-17 at 8 40 00 AM

A very important point: I put / in the path, NOT the full path. This is the relative path for my ftp user once it's logged in. IF you want to put files within a sub-folder, then you must create that sub-folder by logging in using an FTP client program, and creating a subfolder.

I then try creating a backup. Just to make sure that the backup worked, I go to Settings and click "List Files"

Screen Shot 2023-09-17 at 8 46 35 AM

And I can see the file of the last (and only) backup in my account:
Screen Shot 2023-09-17 at 8 46 52 AM

So, as you see, this is working fine. Your issues are either configuration problems, or hosting problems.

tikita commented

Oh how nice, now it finally works for me: uninstalled backup_migrate-1.x-1.x and installed version 1-x.1.0.23.

The module still can't access the top level with the path "/" (it's different for each provider) but with e.g. "/httpdocs" or the subdirectory "/httpdocs/myfolder" Backup and Migrate works fine now in the exchange via FTP.

Thank you Alejandro for your work and for staying so persistent on the problem!

Many greetings from Tikita

PS: With my provider (not all of them) you have to use passive mode for FTP, so check the box "Use PASV transfers" (just below the "Password" field).

Great to know, @tikita . Thanks for your patience. I'll add your notes to the readme

I've added these directions and your comment to the wiki of the module. Thanks.