r/Snipe_IT • u/JGAnyma • Sep 30 '26
Help with error on Backup
Hi, I'm having issues with backups through both the web portal and the console line command.
I'm using snipe-it through the docker compose, and every time I try to back up it gives me the following error.
Of course, I've checked /usr/bin/ on Snipe-it's container, and mariadb-dump is not there, because it's in mariadb's container.
. Error Output
============
sh: 1: /usr/bin/mariadb-dump: not found
.
#0 /var/www/html/vendor/spatie/db-dumper/src/DbDumper.php(200): Spatie\DbDumper\Exceptions\DumpFailed::processDidNotEndSuccessfully()
#1 /var/www/html/vendor/spatie/db-dumper/src/Databases/MySql.php(189): Spatie\DbDumper\DbDumper->checkIfDumpWasSuccessFul()
#2 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(289): Spatie\DbDumper\Databases\MySql->dumpToFile()
#3 [internal function]: Spatie\Backup\Tasks\Backup\BackupJob->Spatie\Backup\Tasks\Backup\{closure}()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(841): array_map()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(829): Illuminate\Support\Arr::map()
#6 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(259): Illuminate\Support\Collection->map()
#7 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(198): Spatie\Backup\Tasks\Backup\BackupJob->dumpDatabases()
#8 /var/www/html/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(172): Spatie\Backup\Tasks\Backup\BackupJob->createBackupManifest()
#9 /var/www/html/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(72): Spatie\Backup\Tasks\Backup\BackupJob->run()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Spatie\Backup\Commands\BackupCommand->handle()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\Container\Util::unwrapIfClosure()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(799): Illuminate\Container\BoundMethod::call()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\Container\Container->call()
#16 /var/www/html/vendor/symfony/console/Command/Command.php(341): Illuminate\Console\Command->execute()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run()
#18 /var/www/html/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(29): Illuminate\Console\Command->run()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(68): Spatie\Backup\Commands\BaseCommand->run()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Concerns/CallsCommands.php(29): Illuminate\Console\Command->runCommand()
#21 /var/www/html/app/Console/Commands/SystemBackup.php(56): Illuminate\Console\Command->call()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\SystemBackup->handle()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\Container\Util::unwrapIfClosure()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(799): Illuminate\Container\BoundMethod::call()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\Container\Container->call()
#28 /var/www/html/vendor/symfony/console/Command/Command.php(341): Illuminate\Console\Command->execute()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run()
#30 /var/www/html/vendor/symfony/console/Application.php(1117): Illuminate\Console\Command->run()
#31 /var/www/html/vendor/symfony/console/Application.php(356): Symfony\Component\Console\Application->doRunCommand()
#32 /var/www/html/vendor/symfony/console/Application.php(195): Symfony\Component\Console\Application->doRun()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(198): Symfony\Component\Console\Application->run()
#34 /var/www/html/artisan(33): Illuminate\Foundation\Console\Kernel->handle()
#35 {main}
Backup failed because: The dump process failed with a none successful exitcode.
Exitcode
========
127: Command not found
Output
======
<no output>
Error Output
============
sh: 1: /usr/bin/mariadb-dump: not foundThis is my .env (The relevant parts)
# --------------------------------------------
# REQUIRED: DATABASE SETTINGS
# --------------------------------------------
# The docker-compose db service uses MariaDB, so we route through the mariadb
# driver so spatie's backup uses mariadb-dump + --skip-ssl.
DB_CONNECTION=mariadb
DB_HOST=db
DB_SOCKET=null
DB_PORT='3306'
DB_DATABASE={db}
DB_USERNAME={user}
DB_PASSWORD={password}
MYSQL_ROOT_PASSWORD={otherpassword}
DB_PREFIX=null
DB_DUMP_PATH='/usr/bin'
# Left off by default: the composed mariadb service has no TLS configured,
# so mariadb-dump connects unencrypted regardless. Opt in only if your
# server actually requires an SSL-skip flag.
DB_DUMP_SKIP_SSL=false
DB_DUMP_SINGLE_TRANSACTION=false
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci
# --------------------------------------------
# OPTIONAL: SSL DATABASE SETTINGS
# --------------------------------------------
DB_SSL=false
DB_SSL_IS_PAAS=false
DB_SSL_KEY_PATH=null
DB_SSL_CERT_PATH=null
DB_SSL_CA_PATH=null
DB_SSL_CIPHER=null
DB_SSL_VERIFY_SERVER=nullEDIT:
I haven't solved it, but I got around it by making a small powershell script that does it for me (I run a docker compose on W11).
<#
.SYNOPSIS
Backs up Snipe-IT (Docker) and archives the result locally and on the network backup folder.
.DESCRIPTION
-Auto Runs the built-in Snipe-IT backup ("php artisan snipeit:backup") in the app container.
WARNING: CURRENTLY NOT WORKING
-Manual Builds the full manual backup: config files, storage volume, MariaDB dump,
zip, copy to network share and move to the local backup folder
If no parameter is given, -Manual is used. If both are given, -Auto runs first, then -Manual.
Every temporary artifact the script creates turns on a flag. When the workflow finishes
(or crashes), Invoke-Cleanup checks every flag and deletes whatever is still flagged.
.EXAMPLE
.\Snipe-IT-Backup.ps1 # same as -Manual
.\Snipe-IT-Backup.ps1 -Auto
.\Snipe-IT-Backup.ps1 -Auto -Manual
#>
[CmdletBinding()]
param(
[switch]$Auto,
[switch]$Manual
)
# If the program finds a non-terminating error, it triggers the catch
# (ErrorActionPreference is a built-in PS variable)
$ErrorActionPreference = 'Stop'
# Default to Manual when no mode is specified
if (-not $Auto -and -not $Manual) { $Manual = $true }
# ---------------- Settings ----------------
$AppContainerName = 'snipe-it-app-1' # runs "php artisan snipeit:backup"
$DbContainerName = 'snipe-it-db-1' # MariaDB container, runs mariadb-dump
$SourceConfigDir = '' # .env and docker compose location
$StorageDataPath = '\\wsl$\docker-desktop\mnt\docker-desktop-disk\data\docker\volumes\snipe-it_storage_data' # WSL data folder
$NetworkShare = '' # Network Backup Folder
$LocalBackupDir = '' #Local Backup Folder
# ------------------------------------------
function Write-Step($msg) { Write-Host "\n=== $msg ===" -ForegroundColor Cyan }`
function Get-ContainerId([string]$Name) {
$id = (docker ps -a --filter "name=^/?$Name$" --format '{{.ID}}' | Select-Object -First 1)
if (-not $id) { throw "Container '$Name' was not found." }
return $id
}
# =====================================================================
# Artifact tracking / cleanup
# =====================================================================
# Each artifact has a flag (Created) and what is needed to delete it.
$script:Artifacts = [ordered]@{
ContainerSql = @{ Created = $false; Path = $null; ContainerId = $null } # temp .sql inside the DB container
NetworkZip = @{ Created = $false; Path = $null } # partial zip on the network share
Zip = @{ Created = $false; Path = $null } # zip in Documents (cleared once moved)
WorkFolder = @{ Created = $false; Path = $null } # work folder in Documents
}
function Set-ArtifactFlag([string]$Name, [string]$Path, [string]$ContainerId = $null) {
$script:Artifacts[$Name].Created = $true
$script:Artifacts[$Name].Path = $Path
if ($ContainerId) { $script:Artifacts[$Name].ContainerId = $ContainerId }
}
function Clear-ArtifactFlag([string]$Name) {
$script:Artifacts[$Name].Created = $false
}
function Invoke-Cleanup {
$flagged = $script:Artifacts.Keys | Where-Object { $script:Artifacts[$_].Created }
if (-not $flagged) { return }
Write-Step 'CLEANUP: Removing generated files'
foreach ($name in $flagged) {
$item = $script:Artifacts[$name]
try {
if ($name -eq 'ContainerSql') {
docker exec $item.ContainerId rm -f $item.Path 2>&1 | Out-Null
}
elseif (Test-Path -LiteralPath $item.Path) {
Remove-Item -LiteralPath $item.Path -Recurse -Force
}
$item.Created = $false
Write-Host "Deleted ($name): $($item.Path)" -ForegroundColor Green
}
catch {
Write-Host "Could not delete ($name): $($item.Path) - $($_.Exception.Message)" -ForegroundColor Yellow
}
}
}
# =====================================================================
# AUTO: built-in Snipe-IT backup
# =====================================================================
function Invoke-AutoBackup {
Write-Step 'AUTO: Listing all Docker containers'
docker ps -a
if ($LASTEXITCODE -ne 0) { throw 'Unable to run "docker ps". Is Docker Desktop running?' }
Write-Step "AUTO: Looking for container '$AppContainerName'"
$appContainerId = Get-ContainerId $AppContainerName
Write-Host "Found container ID: $appContainerId" -ForegroundColor Green
Write-Step 'AUTO: Running Snipe-IT backup inside the app container'
# -it is omitted on purpose so the script also works in non-interactive sessions (e.g. Task Scheduler).
docker exec $appContainerId php artisan snipeit:backup
if ($LASTEXITCODE -ne 0) { throw "snipeit:backup failed (exit code $LASTEXITCODE)." }
}
# =====================================================================
# MANUAL: full manual backup package
# =====================================================================
function Invoke-ManualBackup {
$timestamp = Get-Date -Format 'yyyyMMdd_HHmm'
$folderName = "${timestamp}_SnipeIT_Backup"
$documents = [Environment]::GetFolderPath('MyDocuments')
$workFolder = Join-Path $documents $folderName
$zipPath = Join-Path $documents "$folderName.zip"
Write-Step "MANUAL: Creating work folder: $workFolder"
Set-ArtifactFlag 'WorkFolder' $workFolder # flag first, so a partial creation is cleaned too
New-Item -Path $workFolder -ItemType Directory -Force | Out-Null
Write-Step 'MANUAL: Copying .env and docker-compose.yml'
foreach ($file in '.env', 'docker-compose.yml') {
$src = Join-Path $SourceConfigDir $file
if (-not (Test-Path -LiteralPath $src)) { throw "Missing file: $src" }
Copy-Item -LiteralPath $src -Destination $workFolder -Force
}
Write-Step 'MANUAL: Copying _data folder from the WSL volume'
if (-not (Test-Path -LiteralPath $StorageDataPath)) {
throw "Storage path not found: $StorageDataPath"
}
Copy-Item -LiteralPath $StorageDataPath -Destination (Join-Path $workFolder '_data') -Recurse -Force
Write-Step 'MANUAL: Dumping MariaDB with mariadb-dump'
$dbContainerId = Get-ContainerId $DbContainerName
Write-Host "DB container '$DbContainerName': $dbContainerId" -ForegroundColor Green
# Read DB credentials from the .env that was just copied
$envVars = @{}
Get-Content -LiteralPath (Join-Path $workFolder '.env') | ForEach-Object {
if ($_ -match '^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$') {
$envVars[$Matches[1]] = $Matches[2].Trim().Trim('"').Trim("'")
}
}
foreach ($key in 'DB_DATABASE', 'DB_USERNAME', 'DB_PASSWORD') {
if (-not $envVars[$key]) { throw "$key not found in .env" }
}
$sqlName = "${timestamp}_snipeit_db.sql"
$containerSql = "/tmp/$sqlName"
Set-ArtifactFlag 'ContainerSql' $containerSql $dbContainerId
# Dump inside the container (avoids PowerShell re-encoding the SQL), password passed via env var
`docker exec -e "MYSQL_PWD=$($envVars['DB_PASSWORD'])" $dbContainerId ``
`/usr/bin/mariadb-dump -u $envVars['DB_USERNAME'] ``
`--single-transaction --routines --triggers ``
--result-file=$containerSql $envVars['DB_DATABASE']
if ($LASTEXITCODE -ne 0) { throw "mariadb-dump failed (exit code $LASTEXITCODE)." }
docker cp "${dbContainerId}:$containerSql" (Join-Path $workFolder $sqlName)
if ($LASTEXITCODE -ne 0) { throw 'Could not copy the SQL dump out of the container.' }
Write-Host "Database dump saved as $sqlName" -ForegroundColor Green
Write-Step "MANUAL: Compressing to $zipPath"
if (Test-Path -LiteralPath $zipPath) { Remove-Item -LiteralPath $zipPath -Force }
Set-ArtifactFlag 'Zip' $zipPath
Compress-Archive -Path (Join-Path $workFolder '*') -DestinationPath $zipPath -CompressionLevel Optimal
Write-Step "MANUAL: Copying zip to network share: $NetworkShare"
if (-not (Test-Path -LiteralPath $NetworkShare)) {
New-Item -Path $NetworkShare -ItemType Directory -Force | Out-Null
}
# Flag the share copy only while it is in progress: a half-written file is removed on failure,
# but a finished copy is a real backup and is kept.
Set-ArtifactFlag 'NetworkZip' (Join-Path $NetworkShare "$folderName.zip")
Copy-Item -LiteralPath $zipPath -Destination $NetworkShare -Force
Clear-ArtifactFlag 'NetworkZip'
Write-Step "MANUAL: Moving zip to local backup folder: $LocalBackupDir"
if (-not (Test-Path -LiteralPath $LocalBackupDir)) {
New-Item -Path $LocalBackupDir -ItemType Directory -Force | Out-Null
}
Move-Item -LiteralPath $zipPath -Destination $LocalBackupDir -Force
Clear-ArtifactFlag 'Zip' # the zip now lives in the backup folder: keep it
Write-Host "\nManual backup completed: $folderName.zip" -ForegroundColor Green`
}
# =====================================================================
# Main
# =====================================================================
$exitCode = 0
try {
if ($Auto) { Invoke-AutoBackup }
if ($Manual) { Invoke-ManualBackup }
}
catch {
Write-Host "\nERROR: $($_.Exception.Message)" -ForegroundColor Red`
$exitCode = 1
}
finally {
Invoke-Cleanup # runs on success AND on failure
}
exit $exitCode
1
u/redsnipe Sep 30 '26
Workaround here for now: https://github.com/grokability/snipe-it/issues/19624
1
u/reallylatetotheparty Sep 30 '26
The issue is that Snipe-IT's backup command runs inside the app container, which doesn't ship with mariadb-dump installed. Easiest fix is to exec the dump from the db container directly:
docker compose exec db mariadb-dump --single-transaction -u root -p$MYSQL_ROOT_PASSWORD snipeit > backup.sql. If you want the built-in backup to work, you'd need to addmariadb-clientto the app container's Dockerfile or mount the binary across containers.