error using laravel-webdav(NextCloud) with spatie/backup
aguilerajl opened this issue · 10 comments
Hello,
I'm using spatie/laravel-backup to do backups to a Nextcloud drive (webdav)
'backups' => [
'driver' => 'webdav',
'baseUri' => 'https://nextcloud.com//remote.php/dav/files/user/',
'userName' => 'user',
'password' => '******',
'pathPrefix' => '', // optional
],
The driver works fine. I can use laravel tinker and put or get any file.
But running "php artisan backup:run" produce an error BackupDestination.php(88):
"necessary data rewind wasn't possible"
$handle = fopen($file, 'r+');
// this command catch an error //
**$this->disk->getDriver()->writeStream(
$destination,
$handle,
$this->getDiskOptions()
);**
if (is_resource($handle)) {
fclose($handle);
}
Can you help me?
Thanks in advance
Which version of spatie/laravel-backup
are you running?
Hello, in my composer.json:
"spatie/laravel-backup": "^6.13",
Might this be related to #9?
For me (I reported #9) backup works fine. Using v6.14 of spatie/backup.
I only backup the DB (php artisan backup:run --only-db
)
What does your backup config look like?
Here are the main changes I made (my webdav filesystem is called webdav
, DB is sqlite):
...
'name' => env('APP_NAME', 'laravel-backup') ." ". env('APP_ENV'),
...
'databases' => [
// 'mysql',
env('DB_CONNECTION'),
],
...
'database_dump_compressor' => Spatie\DbDumper\Compressors\GzipCompressor::class,
...
'disks' => [
// 'local',
'webdav',
],
...
Hello, my backup config bellow.
I'm including backup/clean funcionalities and backup both folders and database.
'backup' => [
'name' => env('APP_NAME', 'laravel-backup'),
'source' => [
'files' => [
'include' => [
storage_path('folderInclude'),
],
'exclude' => [ ],
'follow_links' => false,
'ignore_unreadable_directories' => false,
],
'databases' => [
'mysql',
],
],
'database_dump_compressor' => null,
'destination' => [
'filename_prefix' => '',
'disks' => [
env('BACKUP_DRIVE', 'backups'),
],
],
'temporary_directory' => storage_path('app/backup-temp'),
'schedule' => [
'clean_time' => env('CLEAN_TIME', 'backups'),
'backup_time' => env('BACKUP_TIME', 'backups'),
],
],
And in the filesystem config, if I put the first driver work, and the second doesn't work,
'backups' => [
'driver' => 'local',
'root' => storage_path('backups'),
],
'backups' => [
'driver' => 'webdav',
'baseUri' => 'https://nextcloud.com/remote.php/dav/files/userXXX/',
'userName' => 'userXXX',
'password' => '*******',
'pathPrefix' => '', // optional
],
Hello,
Referencing #9, with a slash at the end of the baseUri, all working except backup. There the results:
But, without slash at the end, nothing works. It is very rare that when doing a backup you get this output:
the backup has not been copied.
Hello, referencing #11, this is my new filesystem config, but i continue with the error
'backups' => [
'driver' => 'webdav',
'baseUri' => 'https://nextcloud.com/',
'userName' => 'user',
'password' => '******',
'pathPrefix' => 'remote.php/dav/files/user/',
],
And I updated
"spatie/laravel-backup": "^6.14",
could you try recreating the config file?
It looks quite different than the one I see on my system and in the documentation.
E.g. I don't see schedule
as an option in the config file.
Hello,
These are two entries (schedule) that I have created to facilitate backup planning.
I don't think they have related to the problem because backups work fine if I get a local driver.
Thanks for your help.
Good Sunday :)
Solved.
Read the following module: ..\vendor\sabre\dav\lib\DAV\Client.php
And then, put the authentication/encoding you need
In my case:
'backups' => [
'driver' => 'webdav',
'baseUri' => 'https://nextcloud.com/',
'userName' => 'userXXX',
'password' => '*******',
'pathPrefix' => 'remote.php/dav/files/userXXX/',
'authType' => 1, //Basic authentication
]