snipe-it icon indicating copy to clipboard operation
snipe-it copied to clipboard

Backup error with Docker install

Open mintyhippoxyz opened this issue 3 years ago • 5 comments

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

Describe the bug The php artisan snipeit:backup command fails with error about port not being an integer

root@4acea6c41e59:/var/www/html# php artisan snipeit:backup
Starting backup...

In DbDumper.php line 117:

  Type error: Argument 1 passed to Spatie\DbDumper\DbDumper::setPort() must be of the type integer, string given, called in /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/DbDumperFactory.php on line 36

Backup from the UI also fails with a less informative "something went wrong" error

To Reproduce

  1. Do docker install per documentation
  2. Exec into container and run php artisan snipeit:backup

Expected behavior A backup to be created

Server (please complete the following information):

  • Snipe-IT Version v4.9.4
  • OS: [e.g. Ubuntu, CentOS] Gentoo
  • Web Server: [e.g. Apache, IIS] Apache
  • PHP Version PHP 7.1.33-17+ubuntu16.04.1+deb.sury.org+1

Error Messages

In DbDumper.php line 117:
  Type error: Argument 1 passed to Spatie\DbDumper\DbDumper::setPort() must be of the type integer, string given, called in /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/DbDumperFactory.php on line 36

Additional context

  • Is this a fresh install or an upgrade? fresh
  • What OS and web server you're running Snipe-IT on. Gentoo
  • What method you used to install Snipe-IT (install.sh, manual installation, docker, etc) Docker with mysql:5.6 db container
  • Include what you've done so far in the installation, and if you got any error messages along the way.
  • Indicate whether or not you've manually edited any data directly in the database

I tried explicitly setting port in env file MYSQL_PORT_3306_TCP_PORT=3306 but did not make a difference.

mintyhippoxyz avatar Sep 03 '20 21:09 mintyhippoxyz

Ran into this on v4.9.4, and now on v5-beta5. Thus far I've been able to manually back things up via docker exec <container> bash and mysqldump, but this is really inconvenient.

If anyone that knows more about why this might not work form Docker can provide some clues, I'd be happy to look into opening a PR.

andres-baller avatar Oct 01 '20 15:10 andres-baller

Take a look at #7571, setting DB_PORT=3306 fixed the issue for me.

putz612 avatar Oct 12 '20 15:10 putz612

Can confirm DB_PORT=3306 works for me too. Not sure why MYSQL_PORT_3306_TCP_PORT=3306 didn't for me like noted on that other issue.

Seems the docker documentation could use an update to note this.

mintyhippoxyz avatar Oct 12 '20 20:10 mintyhippoxyz

Could it be related to this line?:

https://github.com/snipe/snipe-it/blob/83200d3cbd5917ea1c2b6dbc6f154491282eb43d/config/database.php#L73

The default value is of type string, whereas public function setPort(int $port) obviously expects an int type. So either the default value should be of type int too or it needs to be casted somewhere later.

thomas-mc-work avatar Feb 25 '22 14:02 thomas-mc-work

Take a look at #7571, setting DB_PORT=3306 fixed the issue for me.

Thanks! Spend a day trying to figure this out. This was my issue as well.

mw-christensen avatar Jul 28 '22 16:07 mw-christensen

Hit by the same issue with the latest v6.0.14 running in docker, fixed by setting DB_PORT=3306 in my env file

lesinigo avatar Apr 03 '23 08:04 lesinigo

Hit by the same issue with the latest v6.0.14 running in docker, fixed by setting DB_PORT=3306 in my env file

Just updated to 6.1.1 after trying to solve this issue with 6.0.14 and it is still the same issue. Unfortunately I was not able to solve it no matter what I entered into the env file.

knmax avatar Jun 15 '23 13:06 knmax