Support

Akeeba Backup for Joomla!

#40859 Akeeba doesn't use existing directory in Google Drive

Posted in ‘Akeeba Backup for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
5.1.1
PHP version
8.2
Akeeba Backup version
9.9.4

Latest post by nicholas on Monday, 24 June 2024 09:16 CDT

peterader

Hello,

I've created a new site and created a backup profile with upload to Google Drive. The specified folder structure exists (except the last directory). I'll explain:

Configured path: myprojects/backup/host  (tried with and without leading slash)

/myprojects/backup/ already exists in Google Drive. "host" directory did not exist from the beginning.

Akeeba however does not use the existing myprojects directory. Instead it creates a new directory with the same name.

When moving the new myprojects to bin, it is still used by Akeeba. When deleting the directory from the bin, it will create a new one with the same name once again.

I've read documentation about ambiguous files/directories in Drive, however this doesn't seem to be a user error as I have no further control other than setting the directory in the config. I'm using the same versions and the same config on other sites. Would you have any suggestions what I can try to solve this?

Thanks, best regards,
Pete

nicholas
Akeeba Staff
Manager

There is really nothing you or us can do about it. I already explained how Google Drive works with folder IDs instead of actual folder names. We ask Google Drive to list folders with that name so we can get the folder ID. If Google Drive, for whatever internal reason, does not return the folder which exists we can't possibly know it exists, therefore we have to try to create a new one. The fact that Google Drive allows that to ever happen is stupid, but here we are.

The only thing I can think of is if you have more than 1000 files and folders in any of the directory levels (myprojects, or myprojects/backups) it might get confused. Listing files and directories normally returns up to 1000 items. Do note that we DO NOT ask it to return all files and folders; we ask it to return ONLY the specific folder. What I can't know is how they have implemented filtering. Do they filter the first 1000 results, or do they actually perform a search? In the first case (which would be completely asinine) I can see how Google would never return the folder that already exists, and I can also see there is no way around it. In the latter case I have no idea why for some people and some people only Google Drive would not find the existing folders. Maybe you have added some spaces? Maybe the spelling is a bit off? Maybe the letter case (uppercase and lowercase letters) of the folders don't match? I have no idea because I cannot reproduce this problem.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

nicholas
Akeeba Staff
Manager

Apparently there has been a recent change. If you connect or reconnect to Google Drive, the generated token only gives permissions to Akeeba Backup to see and manager the files and folders it has created AND NOTHING ELSE. Therefore, trying to use an existing folder on your Drive will not work.

Yes, it is as stupid as it sounds.

My suggestion is to NOT USE GOOGLE DRIVE. It is broken at a fundamental level on Google's side.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

peterader

Hi Nicholas and thanks for looking into it so thoroughly. That's really a surprising result. As you pointed out it has to be a recent change since it didn't behave like this earlier.

I notice the older sites will now also place backups into the new folder so it appears like older access tokens still have access to everything. Very weird indeed and if that's the intended behavior then "stupid", as you phrase is so elegantly, is really spot on.

I managed to fix it by using the same access token/refresh token from an older site where the issue did not appear. Not sure how much of a security issue that opens up though. In the medium/long term I'll probably follow your suggestion and move away from Drive.

Cheers,
Pete

nicholas
Akeeba Staff
Manager

so it appears like older access tokens still have access to everything.

Yes, exactly! That was why I could not reproduce it in the past. I have been using the same Refresh Token in my tests for years. After I sent you my previous reply I created a new Access and Refresh Token pair and I could finally reproduce this.

Just to give you some background on this, the only files returned when I tried listing the entire contents of my Drive (including shared files) where the backup files I had shared from a different account. These files were created with Akeeba Backup. Two different backup archives were not shown: one I uploaded manually to my personal drive, and another one I uploaded manually to the other account and then shared it with my personal account. I also could not see any of the files and folders I had created on my account.

When I used the old Refresh token I had been using for years, yup, I could see everything just fine. Therefore, it's not my code or any change in their API (I checked the API docs to be sure), it's a change in how Google Drive manages permissions.

This actually tracks. They did send us an email that we could no longer use the wide /drive permission we were using before, we had to change to the narrower /drive.file permission, see https://www.akeeba.com/news/1766-google-drive-integration-changes.html for the details. We made this change on May 13th.

I also assume – but have not tested – that if you create a custom OAuth2 Helper as described in our documentation you would be able to use existing folders just fine since the custom helper uses the /drive permission, just like how our software used to do before May 13th.

Still, it boggles the mind that the /drive.file permission which they describe as giving access to all folders and files in the drive does not, in fact, do that; it only gives access to folders and files in the Drive created by the application. It is even more bind-boggling that their solution to the problem they caused is to allow API applications to create folders with identical names as other existing folders! If not having access to your drive's content wasn't confusing enough, having two or more folders with the same name is even worse. Wow. What kind of middle management hellscape do they have over there in Mountain View, California?! Because I can't imagine any engineer in their right mind making this decision and thinking it's a good idea. This has to have come from a middle manager buffoon.

Anyway, yeah, the best approach is to not use Google Drive. It's not even cheap. B2 is much cheaper, about $0.60 / month for 100 GiB compared to Google Drive's $2.15 / month for the same storage space. Even the 2TiB option is basically the same price. Why would anyone want to use Google Drive is beyond me. It makes no economic sense and it doesn't even sync as reliably on as many devices as something like, say, Dropbox does.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!