# How to Backup Your Snipe-IT Database: Complete Guide for Admins

> Learn to backup your Snipe-IT database using the spatie/laravel-backup package. This guide covers web, API, and command line methods for secure cloud or local storage. Protect your IT asset data today.

- Repository: [Grokability, Inc./snipe-it](https://github.com/grokability/snipe-it)
- Tags: how-to-guide
- Published: 2026-07-31

---

**Snipe-IT leverages the spatie/laravel-backup package to generate MySQL database backups through the web interface, API, or command line, storing them securely in `storage/app/backups` by default.**

Managing asset data in the grokability/snipe-it repository requires a reliable backup strategy. The application integrates the **spatie/laravel-backup** package to handle database dumps and file archives, giving administrators multiple ways to protect their inventory data. This guide explains the backup architecture, configuration files, and step-by-step methods to create and restore your Snipe-IT database.

## Snipe-IT Backup Architecture

Understanding how the backup system is wired helps troubleshoot issues and customize behavior. The implementation spans configuration files, controllers, and routes.

### Configuration Files

The primary configuration lives in [`config/backup.php`](https://github.com/grokability/snipe-it/blob/main/config/backup.php), which defines what files and databases to include, retention policies, and storage disks. MySQL connection details and **mysqldump** options are configured in [`config/database.php`](https://github.com/grokability/snipe-it/blob/main/config/database.php) (see line 11 comments referencing spatie backup). For remote storage like S3, disks are defined in [`config/filesystems.php`](https://github.com/grokability/snipe-it/blob/main/config/filesystems.php).

### Web Interface Controller

In [`app/Http/Controllers/SettingsController.php`](https://github.com/grokability/snipe-it/blob/main/app/Http/Controllers/SettingsController.php) at line 901, the `postBackups()` method handles HTTP requests from the admin panel. This method validates admin permissions using `Gate::allows('admin')` before executing the backup command.

### Routes and API Access

Web routes for the backup UI are registered in [`routes/web.php`](https://github.com/grokability/snipe-it/blob/main/routes/web.php) (lines 363-388), exposing the interface under **Settings → Backups**. For programmatic access, API endpoints in [`routes/api.php`](https://github.com/grokability/snipe-it/blob/main/routes/api.php) (lines 982-996) allow external tools to list, download, and trigger backups.

## How to Create a Snipe-IT Database Backup

Administrators can initiate backups through three interfaces depending on their workflow.

### Method 1: Web Interface (Settings → Backups)

Navigate to **Settings → Backups** and click the **"Generate Backup"** button. This POSTs to `SettingsController::postBackups`, which executes the underlying Artisan command. The resulting zip file appears in the backup list once complete.

### Method 2: Command Line (Artisan)

For manual backups or scripting, use the Artisan command from your Snipe-IT root directory:

```bash

# Database-only backup

php artisan backup:run --only-db

# Full backup (database + files)

php artisan backup:run

```

The `--only-db` flag creates a smaller archive containing only the MySQL dump, while omitting it includes uploaded asset files and other storage.

### Method 3: API Endpoint

Authenticated API clients can trigger backups remotely by posting to the backup endpoint defined in [`routes/api.php`](https://github.com/grokability/snipe-it/blob/main/routes/api.php). This is useful for integrating Snipe-IT into broader infrastructure automation tools.

## Scheduling Automatic Backups

To run nightly database backups without manual intervention, add the command to [`app/Console/Kernel.php`](https://github.com/grokability/snipe-it/blob/main/app/Console/Kernel.php):

```php
protected function schedule(Schedule $schedule)
{
    $schedule->command('backup:run --only-db')
             ->dailyAt('02:00')
             ->onFailure(function () {
                 // Optional: notify admin on failure
             });
}

```

The Laravel scheduler requires a system cron entry to trigger every minute:

```bash
* * * * * cd /path/to/snipe-it && php artisan schedule:run >> /dev/null 2>&1

```

## Customizing Backup Settings

Snipe-IT stores backups on the `backup` disk (default: `storage/app/backups`) outside the web root to prevent unauthorized access. Customize behavior by editing [`config/backup.php`](https://github.com/grokability/snipe-it/blob/main/config/backup.php):

- **Retention**: Adjust `keep_all_backups_for_days` and related keys to control how long daily, weekly, and monthly backups are retained.
- **File Inclusion**: Modify the `include` and `exclude` arrays to add directories like custom themes or exclude temporary files.
- **Storage**: Change the `disks` array in [`config/backup.php`](https://github.com/grokability/snipe-it/blob/main/config/backup.php) to use S3 or other remote storage defined in [`config/filesystems.php`](https://github.com/grokability/snipe-it/blob/main/config/filesystems.php).

## Restoring a Snipe-IT Database Backup

Restoration is a manual process performed outside the web interface:

1. **Download** the desired backup from the UI or API to your local machine.
2. **Extract** the zip archive and locate the `.sql` dump file.
3. **Import** the database using MySQL:

```bash
mysql -u snipe_user -p snipe_database < /path/to/extracted/backup.sql

```

4. **Clear caches** to prevent stale data:

```bash
php artisan optimize:clear

```

If restoring to a fresh instance or after schema changes, run migrations after importing:

```bash
php artisan migrate

```

## Summary

- Snipe-IT uses **spatie/laravel-backup** for database and file backups, configured in [`config/backup.php`](https://github.com/grokability/snipe-it/blob/main/config/backup.php).
- Create backups via the **web UI** (Settings → Backups), **Artisan command** `backup:run --only-db`, or **API endpoints**.
- Store backups automatically in `storage/app/backups` or configure remote disks like S3 in [`config/filesystems.php`](https://github.com/grokability/snipe-it/blob/main/config/filesystems.php).
- Schedule automated backups by adding the command to [`app/Console/Kernel.php`](https://github.com/grokability/snipe-it/blob/main/app/Console/Kernel.php) and setting up a system cron.
- Restore by extracting the zip and importing the SQL dump manually, then clearing caches with `php artisan optimize:clear`.

## Frequently Asked Questions

### Where are Snipe-IT backup files stored?

By default, backups are stored in `storage/app/backups` on the local disk named `backup`. This location is outside the web document root to prevent direct URL access. You can configure additional storage disks like Amazon S3 in [`config/filesystems.php`](https://github.com/grokability/snipe-it/blob/main/config/filesystems.php) and reference them in [`config/backup.php`](https://github.com/grokability/snipe-it/blob/main/config/backup.php).

### How do I backup only the Snipe-IT database without files?

Append the `--only-db` flag to the Artisan command: `php artisan backup:run --only-db`. This creates a smaller zip archive containing only the MySQL dump using the **mysqldump** options defined in [`config/database.php`](https://github.com/grokability/snipe-it/blob/main/config/database.php), excluding uploaded asset images and other storage files.

### Can I automate Snipe-IT database backups?

Yes. Add the backup command to [`app/Console/Kernel.php`](https://github.com/grokability/snipe-it/blob/main/app/Console/Kernel.php) inside the `schedule()` method, specifying frequency (e.g., `->dailyAt('02:00')`). Then configure a system cron to run `php artisan schedule:run` every minute. The `postBackups()` method in [`SettingsController.php`](https://github.com/grokability/snipe-it/blob/main/SettingsController.php) demonstrates how the application handles backup generation logic that the scheduler triggers.

### What permissions are required to create or download backups?

Only users with the **admin** role can generate or download backups. The `SettingsController::postBackups()` method explicitly checks `Gate::allows('admin')` before executing backup commands. API endpoints similarly enforce authentication and admin-level authorization.