snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.86k stars 3.14k forks source link

Automatic backups working but manual backups failing #7172

Closed Gauva1n closed 5 years ago

Gauva1n commented 5 years ago

Please confirm you have done the following before posting your bug report:

Describe the bug Automatic weekly backups are being generated perfectly fine, but attempting to manually generate a backup fails and results in an error message of:

Backup failed because: mkdir(): Permission denied.

To Reproduce Steps to reproduce the behavior:

  1. Go to Admin Settings
  2. Click on Backups
  3. Click "Generate Backup"
  4. Error referenced above is displayed

Expected behavior Expect that a backup is generated when manually clicking the "Generate Backup" button.

Screenshots Backup Page Error Screenshot

Server (please complete the following information):

Desktop (please complete the following information):

Error Messages

Additional context

Add any other context about the problem here:

I try to keep SnipeIT updated to the latest version, and this issue started appearing within the last couple updates of SnipeIT. Haven't attempted to run a manual backup in about a month and noticed this when trying to do so today. I've tried the usual fixes of running the artisan config:clear and similar commands, but no luck there. I've tried deleting the vendor directory and reinstalling composer, but that didn't work either. I've checked the settings within the .env file and verified that the credentials it's using to log into the MySQL database are fine, and they are. The tables it's pulling from appear to be all correct as well, and nothing's ever been manually modified within the database.

It looks like this may be related to a permissions issue of some sort. When checking the backup timestamps, it looks like the auto-generated backups are being created as root, yet manual backups are being created under the user snipeitapp that was created for use with SnipeIT. See screenshot below:

Terminal output screenshot

Not quite sure why this is an issue though as the storage, app, and backups directory are all owned by user snipeitapp and have 775 permissions. And again, this process worked fine about a month or so ago and before that point. Possibly something was changed on the update released around June 2nd as it looks like the backup file naming convention changed as well. I'm pretty sure the permissions are the issue here and I'm sure it's something fairly obvious that I'm missing, but just can't connect the final dots. Thanks in advance for any help.

joshatvelocidata commented 5 years ago

I'm actually seeing the same error, also using Ubuntu 18.04.2 LTS and have done the same troubleshooting steps as you describe. This is a new install just completed last week, weekly backup ran fine, I wanted to run a manual one today after adding a number of assets and custom fields. Got the same error you are describing, everything else seems to be functioning correctly.

My system did send me the following error block which I will add here in case it helps hunt down where the difficulty with manual backups is located:

`Important: An error occurred while backing up Snipe-IT Exception message: mkdir(): Permission denied Exception trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'mkdir(): Permis...', '/var/www/snipei...', 42, Array)

1 /var/www/snipeit/vendor/spatie/temporary-directory/src/TemporaryDirectory.php(42): mkdir('/var/www/snipei...', 511, true)

2 /var/www/snipeit/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(134): Spatie\TemporaryDirectory\TemporaryDirectory->create()

3 /var/www/snipeit/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(52): Spatie\Backup\Tasks\Backup\BackupJob->run()

4 [internal function]: Spatie\Backup\Commands\BackupCommand->handle()

5 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)

6 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()

7 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

8 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #9 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\Container\Container->call(Array)

10 /var/www/snipeit/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

11 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Illuminate\Console\OutputStyle))

12 /var/www/snipeit/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(16): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

13 /var/www/snipeit/vendor/symfony/console/Application.php(960): Spatie\Backup\Commands\BaseCommand->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

14 /var/www/snipeit/vendor/symfony/console/Application.php(255): Symfony\Component\Console\Application->doRunCommand(Object(Spatie\Backup\Commands\BackupCommand), Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

15 /var/www/snipeit/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

16 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

17 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Console/Application.php(177): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArrayInput), Object(Symfony\Component\Console\Output\BufferedOutput))

18 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(249): Illuminate\Console\Application->call('backup:run', Object(Illuminate\Support\Collection), NULL)

19 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Illuminate\Foundation\Console\Kernel->call('backup:run')

20 /var/www/snipeit/app/Http/Controllers/SettingsController.php(949): Illuminate\Support\Facades\Facade::__callStatic('call', Array)

21 [internal function]: App\Http\Controllers\SettingsController->postBackups()

22 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)

23 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('postBackups', Array)

24 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\SettingsController), 'postBackups')

25 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\Routing\Route->runController()

26 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\Routing\Route->run()

27 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

28 /var/www/snipeit/app/Http/Middleware/CheckPermissions.php(28): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

29 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckPermissions->handle(Object(Illuminate\Http\Request), Object(Closure), 'superuser') #30 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

31 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

32 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))

33 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

34 /var/www/snipeit/vendor/laravel/passport/src/Http/Middleware/CreateFreshApiToken.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

35 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Laravel\Passport\Http\Middleware\CreateFreshApiToken->handle(Object(Illuminate\Http\Request), Object(Closure))

36 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

37 /var/www/snipeit/app/Http/Middleware/CheckForTwoFactor.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

38 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckForTwoFactor->handle(Object(Illuminate\Http\Request), Object(Closure))

39 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

40 /var/www/snipeit/app/Http/Middleware/CheckLocale.php(42): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

41 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckLocale->handle(Object(Illuminate\Http\Request), Object(Closure))

42 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

43 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

44 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))

45 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

46 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

47 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))

48 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

49 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

50 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure)) #51 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

52 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

53 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\Pipeline\Pipeline->then(Object(Closure))

54 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

55 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route)) #56 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

57 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

58 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))

59 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

60 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))

61 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

62 /var/www/snipeit/app/Http/Middleware/CheckForDebug.php(25): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

63 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckForDebug->handle(Object(Illuminate\Http\Request), Object(Closure))

64 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

65 /var/www/snipeit/app/Http/Middleware/CheckForSetup.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

66 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\CheckForSetup->handle(Object(Illuminate\Http\Request), Object(Closure))

67 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

68 /var/www/snipeit/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

69 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))

70 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

71 /var/www/snipeit/app/Http/Middleware/NosniffGuard.php(17): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

72 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\NosniffGuard->handle(Object(Illuminate\Http\Request), Object(Closure))

73 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

74 /var/www/snipeit/app/Http/Middleware/ContentSecurityPolicyHeader.php(18): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

75 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\ContentSecurityPolicyHeader->handle(Object(Illuminate\Http\Request), Object(Closure))

76 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

77 /var/www/snipeit/app/Http/Middleware/ReferrerPolicyHeader.php(17): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

78 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\ReferrerPolicyHeader->handle(Object(Illuminate\Http\Request), Object(Closure))

79 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

80 /var/www/snipeit/app/Http/Middleware/XssProtectHeader.php(18): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

81 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\XssProtectHeader->handle(Object(Illuminate\Http\Request), Object(Closure))

82 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

83 /var/www/snipeit/app/Http/Middleware/FrameGuard.php(17): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

84 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\Http\Middleware\FrameGuard->handle(Object(Illuminate\Http\Request), Object(Closure))

85 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

86 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

87 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))

88 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

89 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

90 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure)) #91 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

92 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

93 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))

94 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

95 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

96 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))

97 /var/www/snipeit/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

98 /var/www/snipeit/public/index.php(58): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

99 {main}

`

sid8000 commented 5 years ago

I have similar issue. When taking manual backup, backup was generated, but the page is being redirected to "Whoops, looks like something went wrong". But if I reload the page I see generated backup file. I can even download that file. Server OS - Windows 7 with WAMP SnipeIT version - v4.7.5

sspencerwire commented 5 years ago

I have confirmed this as an issue and can see that the automated backups that are created in the back end on a CentOS 7 container are owned by root, whereas the snipeit user is what I think is trying to generate the backups from the manual backup process. I checked my directory:

/var/www/html/snipeit/storage/app/backups And the automatic backups are owned by root the directory /backups is owned by snipeit.apache, and there is also a ../backup-temp directory that is owned by root.root Version: v4.7.5 build 4118 (g03a451240) Laravel Version: 5.5.45 PHP Version: 7.1.23

In my case, we snapshot the entire container after major changes, so it isn't as big a deal that the manual backup isn't working.

empressalae commented 5 years ago

I can confirm this on CentOs as well. if I chmod the entire storage folder to 777, the backups work, on my machine they're being created by apache and not even by the snipeit user

0 drwxrwxrwx 3 snipeitapp apache     323 Jul  8 05:53 .
3608 -rw-r--r-- 1 apache     apache 3690695 Jul  8 05:53 snipe-it-2019-07-08-05-53-37.zip
3608 -rwxrwxrwx 1 apache     apache 3690695 Jul  8 05:21 snipe-it-2019-07-08-05-21-11.zip

You'll note the folder itself has group access for apache, but even then if I do 755, it still fails, I've even tried 766 and 776, this literally causes the backup page to go "whoops, something went wrong" so obviously there's something that requires execute that is not clearly documented.

apache:x:48:snipeitapp
mysql:x:27:
snipeitapp:x:1002:mysql

I even tried adding mysql to snipeit on the incredibly off chance it was something that sql needed to do.

snipe commented 5 years ago

That looks more like a linux permissions issue than anything else. If you run something via the web GUI, its always going to run as whatever user your web server runs as, versus when you run it via cli, it runs as whatever user you're logged in as. Without details on your "Whoops", I don't have a way to troubleshoot that, but I'm 99% certain it's a group/owner/permissions issue. If you look at your app log, I'd bet you'll see a permissions error.

empressalae commented 5 years ago

That looks more like a linux permissions issue than anything else. If you run something via the web GUI, its always going to run as whatever user your web server runs as, versus when you run it via cli, it runs as whatever user you're logged in as. Without details on your "Whoops", I don't have a way to troubleshoot that, but I'm 99% certain it's a group/owner/permissions issue. If you look at your app log, I'd bet you'll see a permissions error.

Question, the error I see is failed to create directory, where is it trying to create a directory that in a 775 folder it's not able to do so? When it's done there are no directories added to backups that I recall seeing.

snipe commented 5 years ago

I believe that backup system creates a tmp directory (that it then deletes), so the storage directory and everything in it needs to be writable.

Gauva1n commented 5 years ago

Coming back to this issue very late, but was talking to some others in a sysadmin Slack channel and found the fix. Did some digging and found at some point in time permissions had gotten twisted around and some files within the ./storage directory were chowned to another user, maybe during an upgrade? Regardless, ran:

sudo chown -R www-data:www-data ./storage sudo chmod -R 755 ./storage

Then just ran the typical artisan cache:clear and related commands, confirmed manual backups were working (they were), and now peace is restored to the kingdom once more. Thanks for all chiming in to help when I had the dumb and couldn't brain.

MSWork79 commented 4 years ago

If that's not a huge reminder to not just copy/paste commands without looking. If you sudo chown -R 755 ./storage bad things happen. In case anyone else is as dumb as I am and ran the code above it should have read 'chmod' not 'chown' for the 2nd line.

Basically the above just changed ownership to user/group www-data and then immediately changed it over to the USER 755.

Completely removed access to everything. Website was showing zero assets/users/etc. until I ran a ls -l and was like "hey since when does user/group 755 own stuff"

Gauva1n commented 4 years ago

Oh boy, thanks for catching that. Apologies for the mistype. I've corrected it in my above comment so no one else gets tripped up.

MSWork79 commented 4 years ago

No problem! I just wish I would have noticed it before I copy/pasted into Putty lol