Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot restore backup #13515

Closed
2 tasks done
BlackRose01 opened this issue Aug 23, 2023 · 5 comments · Fixed by #14379
Closed
2 tasks done

Cannot restore backup #13515

BlackRose01 opened this issue Aug 23, 2023 · 5 comments · Fixed by #14379
Assignees

Comments

@BlackRose01
Copy link

Debug mode

Describe the bug

Hello,

I had to delete my Snipe-IT container because I wanted to add some more information to the container as a label. When I recreated the container, all the information was still there but all the uploaded images were gone (not a problem and was in the back of my mind). For this reason, I wanted to restore the previously created backup but this did not work. Via the website I always received an HTTP Error 500 and when restoring in the container using PHP artisan the error that the file was not found. I used the relative as well as the absolute file path.

KR,
BlackRose01

Reproduction steps

  1. Log In on the Snipe-It Webpage and go to Setting/Backups
  2. Restore backup

  1. Exec into the container docker exec -ti snip /bin/bash
  2. Restore the uploads via php artisan snipeit:restore /var/www/html/storage/app/backups/snipe-it-manual-backup-2023-08-23-13-10-31.zip

Expected behavior

Restore all information and images, so that they can be used.

Screenshots

Restore from Bash

Bild_2023-08-23_142713528

Restore from Website

2023-08-23_142759

Snipe-IT Version

v6.1.2 build 10938 (g32747cafd)

Operating System

Official Docker Image

Web Server

Official Docker Image

PHP Version

8.1.2-1ubuntu2.13 | Laravel: 8.83.22

Operating System

Windows 11

Browser

Opera GX

Version

LVL5 (core: 100.0.4815.82)

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

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



   1/107 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]   0%
   ErrorException

  fopen(public/uploads/assets/assets): Failed to open stream: No such file or directory

  at app/Console/Commands/RestoreFromBackup.php:304
    300▕         foreach ($interesting_files as $pretty_file_name => $file_details) {
    301▕             $ugly_file_name = $za->statIndex($file_details['index'])['name'];
    302▕             $fp = $za->getStream($ugly_file_name);
    303▕             //$this->info("Weird problem, here are file details? ".print_r($file_details,true));
  ➜ 304▕             $migrated_file = fopen($file_details['dest'].'/'.basename($pretty_file_name), 'w');
    305▕             while (($buffer = fgets($fp, self::$buffer_size)) !== false) {
    306▕                 fwrite($migrated_file, $buffer);
    307▕             }
    308▕             fclose($migrated_file);

  1   app/Console/Commands/RestoreFromBackup.php:304
      fopen()

      +13 vendor frames
  15  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

Additional context

Fresh Snipe-IT container but old database container

@uberbrady
Copy link
Collaborator

We normally use a special Docker volume to handle the various uploads, so you should be able to throw away the container and replace it, and if you mount that volume, the various attached files should just show up.

The path public/uploads/assets/assets seems a little weird, I don't know what's going on there.

You may want to take a look at your ZIP file and see if it has that strange assets/assets/ structure as well? And/or take a look at the filesystem on your docker container.

@BlackRose01
Copy link
Author

Mhh... But I don't know where the path public/uploads/assets/assets is coming from. If you have a look on top in the image Restore from Bash then you can see that I don't choose this path.

@snipe
Copy link
Owner

snipe commented Sep 15, 2023

I genuinely don't know where it would be getting that path from. Maybe something weird with paths in windows? If you open your backup zip, do you see an assets/assets folder?

@csayre
Copy link

csayre commented Sep 22, 2023

Hello all,

I am having this issue too. I have examined my backup.

Here is my folder path
var\www\html\snipeit\public\uploads\assets\

Under the assets folder, it appears that there are images that are in there, but no folder or file called assets.

Currently, there are some images that are in the assets folder. I have tried creating this path var\www\html\snipeit\public\uploads\assets\assets\ but that seems to fail as well. It does look like I was getting a little bit further than @BlackRose01, my process seems to fail at 96/159.

Notes about my env:
I am attempting to migrate from a Virtual Machine where Snipe-IT is currently running to a docker environment.
The VM and the docker env are both linux.
The VM is running 5.0.13-prebuild
The Docker Container is running the latest version of snipe-IT

Console Output

I should also note that it appears to have restored bits and pieces of the application. For example, AD authentication, and our login banner.

@christiangierschner
Copy link

Same issue here on v6.2.3 vanilla system

Try this...it worked for me...
I think, restore should create folders itself...

mkdir -p /var/www/html/public/uploads/assets/
php artisan snipeit:restore /full/path/to/your/backup.zip

Greets

Chris Ti An

snipe added a commit that referenced this issue Mar 7, 2024
@snipe snipe closed this as completed in b65bf50 Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@uberbrady @snipe @csayre @BlackRose01 @christiangierschner and others