I am using the google drive adapter from https://github.com/nao-pon/flysystem-google-drive
The adapter itself seems to be working as it should. For instance, a test route that saves a simple file and it is stored correctly.
Route::get('test', function() {
Storage::disk('google')->put('test.txt', 'Hello World');
});
When I run php artisan backup:run I get the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: .",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: ."
}
}
There is more to the error dump but that seems to be the relevant information.
Unfortunately I don't use Google Drive, so I can't easily reproduce this.
Can you see on what line of code in our package this error is being generated?
Well I only posted here because it works as a filesystem within the application, just not within the backup application. I posted the whole error dump is at https://gist.github.com/anonymous/3b807cf2d37436bf539dad8fa4005056#file-lvbackup as to not clutter this issue form.
What is the value of config('laravel-backup.backup.name')?
It's was set at the default which is 'name' => env('APP_URL'),
The value in the .env file was 'APP_URL=http://localhost'
I changed this to the FQDN of my server which is an Authorized redirect URI listed in the google drive api for my app.
Still no change, looks like the same error message.
It's a long shot but maybe Google Drive has a problem with special characters such a : and /. Could you try setting that config value to something simple without special characters?
Nope didn't change anything... same error code. :'(
I am currently finished from settings of this issue, i don't know where is the problem but i changed the used google email to another and it is work.
but i faced another problem when i run backup, the message appear :
/var/www/# php artisan backup:run
Starting backup...
Dumping database laravel_almeyyah...
Determining files to backup...
Zipping 3664 files...
Created zip containing 3664 files. Size is 482.71 MB
Copying zip to disk named google...
Copying zip failed because: Invalid request. The number of bytes uploaded is required to be equal or greater than 262144,
except for the final request (it's recommended to be the exact multiple of 262144).
The received request contained 8192 bytes, which does not meet this requirement..
Backup completed!
please if any one can help me
@greatsami i have the same problem when trying to create a backup to Google Drive on the production server, but on the local testing server the upload is working just fine.
I can't figure out what the problem is on the production server.
This is the message that appears:
Starting backup...
Dumping database MailWeb...
Determining files to backup...
Zipping 37 files...
Created zip containing 37 files. Size is 76.29 KB
Copying zip to disk named google...
Copying zip failed because: Invalid request. The number of bytes uploaded is required to be equal or greater than 262144, except for the final request (it's recommended to be the exact multiple of 262144). The received request contained 8192 bytes, which does not meet this requirement..
Backup completed!
@Wijnands
I tried to solve this issue manually and i success in upload side, but the email received it tell me the backup is failed (but it is problem with me until Mr. @freekmurze solve this issue :) ).
my solution is: edit (write function) in:
vendor/spatie/laravel-backup/src/BackupDestination/BackupDestination.php
if (is_null($this->disk)) {
throw InvalidBackupDestination::diskNotSet();
}
$destination = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_BASENAME);
\Storage::disk('google')->put(''.pathinfo($file, PATHINFO_BASENAME).'', file_get_contents($destination));
/*
$destination = $this->backupName.'/'.pathinfo($file, PATHINFO_BASENAME);
$handle = fopen($file, 'r+');
$this->disk->getDriver()->writeStream($destination, $handle);
if (is_resource($handle)) {
fclose($handle);
}
*/
regards
@greatsami your solutions works for me, thanks for that!
But the funny thin is that it only works on my production server and not on my local server.
For now it is a workaround but i hope that there is a more permanent solution for this.
I am also facing the same 'file not found' error like @cringer
I explored it further and it looks like Google API doesn't allow to read files based on filename. See https://github.com/nao-pon/flysystem-google-drive/issues/16 and the error 'file not found' corresponds to this.
So my guess is that laravel-backup is trying to read files by name from the filesystem and since Google API doesn't allow that it is generating the above error.
@greatsami @Wijnands
Nao Pon has fixed the package, so update your flysystem-google-drive.
Another way to solve this, is set memory_limit (php.ini), it cant be -1.
Reference: https://github.com/nao-pon/flysystem-google-drive/issues/15
Closing this because the bug has been fixed in the underlying package (see answer from @vitorfavila)
Thanks everybody for pinching in.
@freekmurze
Actually the changes to filesystem-google-drive only fixes the issues that @Wijnands was facing.
The original issue that @cringer reported is still happening with the latest version of both filesytem-google-drive and laravel-backup.
@sudar ah, ok, misread that, reopening...
I had the same problem and here is my solution:
File Not Found Exception throws on line 85 of Spatie\Backup\BackupDestination\BackupDestination file.
In line 81 of that file $this->backupName added to file destination to create a directory named app url.
So google drive don't support this type of creating directory.
To resolve you may set config('laravel-backup.backup.name') to empty ( '' ).
@dena-a
Thanks. That explains the reason why we were getting the exception.
@freekmurze
Would it be possible to make the backup file name/directory configurable so that we can set it to a name without . when using with Google Drive API?
I’d accept a fully tested PR that fixes this
On Mon, 14 Aug 2017 at 12:43, Sudar Muthu notifications@github.com wrote:
@dena-a https://github.com/dena-a
Thanks. That explains the reason why we were getting the exception.
@freekmurze https://github.com/freekmurze
Would it be possible to make the backup file name/directory configurable
so that we can set it to a name without . when using with Google Drive
API?—
You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub
https://github.com/spatie/laravel-backup/issues/468#issuecomment-322158862,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAdiDZI8JS84ogEx2DejHqQR598WbvfXks5sYCTRgaJpZM4N74e5
.>
Freek Van der Herten https://spatie.be +32 495 84 27 91
That error is because you can't use the folder name you have to get the folder ID of the google drive folder, that's because google drive allow duplicated names, so the unique name in that case is the id, create a folder on google drive and open that folder, now go to the url:
https://drive.google.com/drive/u/1/folders/id_of_the_folder
Now configure the file like this:
'backup' => [
/*
* The name of this application. You can use this name to monitor
* the backups.
*/
'name' => 'id_of_the_folder',
Hi everyone, I tested creating a backup on google drive and it works. But there are 2 following notes:
null and in the package's config backup.php specify the name as blank ''. You don't need to modify package's source code for this. This is because google uses the folder ID's as an identifier as names could be similar.+1
Thanks!
@ThiagoLovatine It's Worked I Just Change The Name To My Id Folder And Its Worked
Thanks
@ThiagoLovatine that worked for me for php artisan backup:run and backup:clean for backup:list and backup:monitor I get
In REST.php line 118:
```
{
"error": {
"errors": [
{
"domain": "global",
"reason": "notFound",
"message": "File not found: .",
"locationType": "parameter",
"location": "fileId"
}
],
"code": 404,
"message": "File not found: ."
}
}
```
someone knows how to avoid that the deleted backups land in trash and fill up storage anyway?
Thanks, @ThiagoLovatine and other sugestions. It's working for me.
@dena-a Thanks. It's working for me.
i had this same error beause i was backing up to multiple destinations. My walkaround was to edit the file Spatie\Backup\BackupDestination\BackupDestination
public function backupName(): string
{
if ($this->disk == "google") {
return env('GOOGLE_DRIVE_FOLDER_ID', '');
} else {
return $this->backupName;
}
}
@introwit solution worked, it also worked without changing the GOOGLE_DRIVE_FOLDER_ID to null
@introwit Thank you for your help, but I want to pay attention to the fact that if you do not set a name, the backup files will be saved to the path /storage/app and this folder will be excluded from the backup. In my case need to save images from /storage/app/public.
Therefore, if you need to files from '/storage/app' it is better to set the name as env('GOOGLE_DRIVE_FOLDER_ID') and you will save all files from '/storage/app/*'
I need to keep a local copy and also a google one.
Not sure why, but if I have a name in backup, it will always override GOOGLE_DRIVE_FOLDER_ID and said the folder not found.
It only work if I set the backup name to GOOGLE_DRIVE_FOLDER_ID or '', but the the local one, it will put into a very long google drive folder id or if '' is used, it put to /storage/app.
I was getting error "message": "File not found: 6666666Jo8AWLW-LI-XSR5n4z_7KVfNer."
The reason is in the name of the folder that was generated by Google Drive.
Because when I created a new folder, it had a new name "888888RrZx-wXq91XVWd9ZsfrK8X6-yZ" - everything worked.
I think the problem was because of the underscore in GOOGLE_DRIVE_FOLDER_ID.
i also have same issue but solution just pass empty name like this
` 'backup' => [
/*
* The name of this application. You can use this name to monitor
* the backups.
*/
'name' => config('GOOGLE_DRIVE_FOLDER_ID' , ''),
'source' => [`
the issue is that we are passing name most of time on upload name not match and it gives error when you pass null then it store that backup which is created at that time
Most helpful comment
That error is because you can't use the folder name you have to get the folder ID of the google drive folder, that's because google drive allow duplicated names, so the unique name in that case is the id, create a folder on google drive and open that folder, now go to the url:
https://drive.google.com/drive/u/1/folders/id_of_the_folder
Now configure the file like this:
'backup' => [