snipe / snipe-it

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

Restore from Backup File - Not working #10714

Closed jmartins1 closed 2 years ago

jmartins1 commented 2 years ago

Debug mode

Describe the bug

Using any of the backup restore options from the "Restore from Backup File" page produces an error.

Ref: https://snipe-it.readme.io/docs/restore-from-backup-file

Reproduction steps

  1. Create a backup manually through the Snipe-IT inventory interface
  2. Run the restore command found on https://snipe-it.readme.io/docs/restore-from-backup-file php artisan snipeit:restore C:/backup.zip

I'm not sure if there is a different path format I should be using on Windows. I have tried:

php artisan snipeit:restore //backup.zip php artisan snipeit:restore c://backup.zip php artisan snipeit:restore c:\backup.zip php artisan snipeit:restore c:\backup.zip

None appear to work

  1. Error ... 2022-02-22_12-25-59

Expected behavior

Backup DB restoration

Screenshots

2022-02-22_12-25-59

Snipe-IT Version

5.3.10

Operating System

Windows 11

Web Server

WAMP 3.2.5

PHP Version

7.4.9

Operating System

WIndows 11

Browser

Chrome

Version

98.0.4758.102 (Official Build) (64-bit)

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

Screenshot attached

Additional context

No response

snipe commented 2 years ago

How big is the file you're trying to restore?

jmartins1 commented 2 years ago

I’ve tried two.

One: 14.6 MB

The other: 1.26 MB

Jaysunusn commented 2 years ago

I'm having a similar issue. C:\inetpub\wwwroot\snipe-it>php artisan snipeit:restore C:\inetpub\wwwroot\snipe-it\storage\app\backups\snipe-it-2022-03-22-18-45-00.zip Current working directory is: C:\inetpub\wwwroot\snipe-it

Are you sure you wish to restore from the given backup file? This can lead to MASSIVE DATA LOSS! (yes/no) [no]:

yes

Found a sql file!

ErrorException : fwrite(): write of 52 bytes failed with errno=22 Invalid argument

at C:\inetpub\wwwroot\snipe-it\app\Console\Commands\RestoreFromBackup.php:240 236| } 237| 238| while(($buffer = fgets($sql_contents)) !== false ) { 239| //$this->info("Buffer is: '$buffer'");

240| $bytes_written = fwrite($pipes[0],$buffer); 241| if($bytes_written === false) { 242| $stdout = fgets($pipes[1]); 243| $this->info($stdout); 244| $stderr = fgets($pipes[2]);

Exception trace:

1 fwrite() C:\inetpub\wwwroot\snipe-it\app\Console\Commands\RestoreFromBackup.php:240

2 App\Console\Commands\RestoreFromBackup::handle() C:\inetpub\wwwroot\snipe-it\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36

Please use the argument -v to see more details.

snipe commented 2 years ago

I don't think we've tested the restore script extensively on Windows, but it does look like both you and the OP are running WAMP. Is it possible the temp directory isn't writable or the file isn't readable by the user who is attempting to do the restore?

https://github.com/snipe/snipe-it/blob/729b23c0cfd160f47fc74875d3856d42f08f7f86/app/Console/Commands/RestoreFromBackup.php#L238-L248

uberbrady commented 2 years ago

I suspect we're not properly launching the mysql command-line binary - pathing issues are often a problem on Windows :/

If there's a way you can ensure that you can run mysql from the command line (perhaps by adding its directory to the PATH environment variable) then you might have better luck?

jmartins1 commented 2 years ago

Just an FYI, you probably already know but just to be sure... inetpub is part of Microsoft Internet Information Services (IIS). It's not related to WAMP Server.

Jaysunusn commented 2 years ago

Yes it's IIS, I just attached to this thread as I have a similar issue. Uberbrady, you seem to be on to something there, but I'm not sure the next step. Can you elaborate.

uberbrady commented 2 years ago

I don’t know how path variables work on Windows. But, your mysql binary lives somewhere on your system. Whatever directory it lives in, needs to be added to your path. Then, if you log out and log back in to your Windows session, you should be able to type mysql on the command-line and it should launch the binary.

What may be confusing this is that it’s possible that your web server has a different concept of what the path environment variable is. But let’s just start with using the Artisan command-line tool to start with and work our way over.

I did a little googling and this is what I was able to come up with: https://www.computerhope.com/issues/ch000549.htm

How to set the path and environment variables in Windows
Information on how to set the path and environment variables in Windows 2000, Windows XP, Windows Vista, and Windows 7.
Jaysunusn commented 2 years ago

Just updating. I'm working on this all day. I made sure under under my environment variables by going to windows x, system, environment variables, that there is a PHP path pointing at my PHP Folder under C:\PHP7 Just to be sure deleted it and restored it. I'm not sure how to test mysql. If I just launch cmd and type mysql I get C:\inetpub\wwwroot\snipe-it>mysql 'mysql' is not recognized as an internal or external command, operable program or batch file.

Still researching...

Jaysunusn commented 2 years ago

Not sure if it matters, but I'm using MariaDB

Jaysunusn commented 2 years ago

Okay, I misunderstood. Since it appears like a PHP issue I was working the wrong problem. Added Mariadb path in my environment variables. Restarted the server. Restore still fails. Verified under services Mariadb is running. Trying to figure out how to test it at the cmd line

Jaysunusn commented 2 years ago

C:\Program Files\MariaDB 10.6\bin>mysql -u root -p Enter password: ** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 4 Server version: 10.6.7-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> MariaDB [(none)]>

uberbrady commented 2 years ago

I just ran into this on our own hosted platform. When I tried to extract the mysql dump file from the zip, then manually pipe it into the mysql command-line client, I got the following error message:

ERROR 1193 (HY000) at line 14: Unknown system variable 'GTID_PURGED'

So I think what happened here is that the mysql dump file I was working with is from a newer version of mysql than the one I'm using. I simply deleted the appropriate line (SET @@GLOBAL.GTID_PURGED='';) from the SQL file and then the mysql import worked.

It sure would be a lot nicer if we had a way to catch the error that MySQL spits out and display it to the user rather than the cryptic "fwrite failed" error message :/

snipe commented 2 years ago

More info here: https://stackoverflow.com/questions/45858723/error-1193-hy000-unknown-system-variable-gtid-purged

Stack Overflow
ERROR 1193 (HY000): Unknown system variable 'GTID_PURGED'
I took backup of database from workbench from a remote server. So when I import it on my local environment I got error: ERROR 1193 (HY000): Unknown system variable 'GTID_PURGED' I'm using xampp
toti-feroy commented 2 years ago

Hi snipe, I am having a similar issue with the backup restore. I tried to restore directly on the GUI app using the restore button and since then have been stock with the error 500. log report can be seen below. thanks you for assistance.

log report:

[2022-06-08 09:17:23] production.ERROR: Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length() {"exception":"[object] (Error(code: 0): Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length() at C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Encryption\Encrypter.php:100) [stacktrace]

0 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(149): Illuminate\Encryption\Encrypter->encrypt('b97ccf5a8e5c819...', true)

1 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(67): Illuminate\Cookie\Middleware\EncryptCookies->encrypt(Object(Illuminate\Http\Response))

2 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))

3 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

4 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Routing\Router.php(723): Illuminate\Pipeline\Pipeline->then(Object(Closure))

5 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Routing\Router.php(698): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

6 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Routing\Router.php(662): Illuminate\Routing\Router->runRoute(Object(Illuminate\Http\Request), Object(Illuminate\Routing\Route))

7 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Routing\Router.php(651): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

8 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(167): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

9 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(128): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))

10 C:\wamp\www\inventory\vendor\livewire\livewire\src\DisableBrowserCache.php(19): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

11 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Livewire\DisableBrowserCache->handle(Object(Illuminate\Http\Request), Object(Closure))

12 C:\wamp\www\inventory\vendor\barryvdh\laravel-debugbar\src\Middleware\InjectDebugbar.php(67): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

13 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Barryvdh\Debugbar\Middleware\InjectDebugbar->handle(Object(Illuminate\Http\Request), Object(Closure))

14 C:\wamp\www\inventory\vendor\fruitcake\laravel-cors\src\HandleCors.php(38): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

15 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Fruitcake\Cors\HandleCors->handle(Object(Illuminate\Http\Request), Object(Closure))

16 C:\wamp\www\inventory\app\Http\Middleware\PreventBackHistory.php(23): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

17 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): App\Http\Middleware\PreventBackHistory->handle(Object(Illuminate\Http\Request), Object(Closure))

18 C:\wamp\www\inventory\app\Http\Middleware\SecurityHeaders.php(26): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

19 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): App\Http\Middleware\SecurityHeaders->handle(Object(Illuminate\Http\Request), Object(Closure))

20 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

21 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illuminate\Http\Request), Object(Closure))

22 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle(Object(Illuminate\Http\Request), Object(Closure))

23 C:\wamp\www\inventory\app\Http\Middleware\CheckForDebug.php(25): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

24 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): App\Http\Middleware\CheckForDebug->handle(Object(Illuminate\Http\Request), Object(Closure))

25 C:\wamp\www\inventory\app\Http\Middleware\CheckForSetup.php(32): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

26 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): App\Http\Middleware\CheckForSetup->handle(Object(Illuminate\Http\Request), Object(Closure))

27 C:\wamp\www\inventory\vendor\fideloper\proxy\src\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

28 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Fideloper\Proxy\TrustProxies->handle(Object(Illuminate\Http\Request), Object(Closure))

29 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

30 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))

31 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(121): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

32 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(64): Illuminate\Session\Middleware\StartSession->handleStatefulRequest(Object(Illuminate\Http\Request), Object(Illuminate\Session\Store), Object(Closure))

33 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))

34 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php(86): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

35 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle(Object(Illuminate\Http\Request), Object(Closure))

36 C:\wamp\www\inventory\app\Http\Middleware\NoSessionStore.php(28): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

37 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(167): App\Http\Middleware\NoSessionStore->handle(Object(Illuminate\Http\Request), Object(Closure))

38 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(103): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))

39 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(142): Illuminate\Pipeline\Pipeline->then(Object(Closure))

40 C:\wamp\www\inventory\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(111): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

41 C:\wamp\www\inventory\public\index.php(52): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

42 {main}

"}

snipe commented 2 years ago

Is it possible your APP_KEY changed from what it used to be and whatever the current APP_KEY is?

toti-feroy commented 2 years ago

Thank you for the responds. the APP_KEY didn't change. I had to restore the system from a manual backup I had. I will try the using the restore again hopefully it works this time.

Thanks

wikilike7 commented 2 years ago

Thank you for the responds. the APP_KEY didn't change. I had to restore the system from a manual backup I had. I will try the using the restore again hopefully it works this time.

Thanks

+1, I have same error, WAMP,click the restore button will occures server error 500.

Did you resolved this issue ?

toti-feroy commented 2 years ago

Not yet, I will have to create a new test environment before trying again.

On Tue, Jun 21, 2022 at 11:32 PM wikilike7 @.***> wrote:

Thank you for the responds. the APP_KEY didn't change. I had to restore the system from a manual backup I had. I will try the using the restore again hopefully it works this time.

Thanks

+1, I have same error, WAMP,click the restore button will occures server error 500.

Did you resolved this issue ?

— Reply to this email directly, view it on GitHub https://github.com/snipe/snipe-it/issues/10714#issuecomment-1162627680, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQRH6POOZHUFN5MAVTAKTKTVQKJPVANCNFSM5PCKCZOQ . You are receiving this because you commented.Message ID: @.***>

allexxy commented 2 years ago

Thanx so much! Will have some time tonite, I hope.

On Sunday, June 26, 2022, toti-feroy @.***> wrote:

Not yet, I will have to create a new test environment before trying again.

On Tue, Jun 21, 2022 at 11:32 PM wikilike7 @.***> wrote:

Thank you for the responds. the APP_KEY didn't change. I had to restore the system from a manual backup I had. I will try the using the restore again hopefully it works this time.

Thanks

+1, I have samex so much? error, WAMP,click the restore button will occures server error 500.

Did you resolved this issue ?

— Reply to this email directly, view it on GitHub <https://github.com/snipe/snipe-it/issues/10714#issuecomment-1162627680 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ AQRH6POOZHUFN5MAVTAKTKTVQKJPVANCNFSM5PCKCZOQ . You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/snipe/snipe-it/issues/10714#issuecomment-1166499015, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWXRVHLED7H4C6D2EZFAALVRA34BANCNFSM5PCKCZOQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- regards,

Elamar Yarden, Adv.

Elamar Yarden, Law Office Tel: +972-52-5533353 e-mail: @.***


Important Note: This e-mail message and any files transmitted with it are subject to attorney-client privilege and contain confidential information intended only for the addressee(s). Please note that any disclosure, copying or distribution of the content of this information is strictly forbidden. If you have received this e-mail message in error, please destroy it immediately and notify us by e-mail or call: +972-52-5533353

snipe commented 2 years ago

For those having the cipher issue, can you tell me what version you were upgrading from?

snipe commented 2 years ago

(Also if you don’t have any encrypted fields, you can try regenerating your APP_KEY)

snipe commented 2 years ago

Hi there - We haven't heard back in a bit, so I'm going to close this ticket for now, but will re-open it if you're still having issues.

hackerman-hacking

jmartins1 commented 1 year ago

No, my updates are consistent; I use a powershell script to automate updates. The .env file is copied over from the previous installation. I also compare the .env file against the new .envexample file for updates.

Also, using MySQL Workbench I do not have any issues importing the DB.

From: snipe @.> Sent: Wednesday, June 8, 2022 9:37 AM To: snipe/snipe-it @.> Cc: jmartins1 @.>; Author @.> Subject: Re: [snipe/snipe-it] Restore from Backup File - Not working (Issue #10714)

Is it possible your APP_KEY changed from what it used to be and whatever the current APP_KEY is?

— Reply to this email directly, view it on GitHub https://github.com/snipe/snipe-it/issues/10714#issuecomment-1150080278 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOF6F627L7WAIMOWY3DCATVOC4ZRANCNFSM5PCKCZOQ . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AHOF6FY5YSXGS2C5C75SKC3VOC4ZRA5CNFSM5PCKCZO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOISGNKFQ.gif Message ID: @. @.> >