TSF – Giải pháp IT toàn diện cho doanh nghiệp SMB | HCM

P9 - SnipeIT Manual Backup on Ubuntu, Cron Schedule, Restore Tutorial

SnipeIT – P9 Full SnipeIT on Ubuntu Manual Backup, Cron Schedule & Restore Tutorial

Backing up your Snipe-IT system is not optional — it is critical.

In production environments, Snipe-IT stores valuable asset data, user information, license tracking, and file uploads. A server crash, disk failure, or misconfiguration can result in permanent data loss if you do not have a proper backup strategy.

In this tutorial, you will learn how to:

  • ✅ Perform a full Snipe-IT backup (files + database)

  • ✅ Run manual backups via CLI

  • ✅ Automate backups using cron jobs

  • ✅ Restore Snipe-IT from backup

  • ✅ Apply best practices for permissions and security

This guide works for:

  • Ubuntu Server 20.04

  • Ubuntu Server 22.04

  • Newer Ubuntu versions

By the end of this tutorial, you will confidently manage Snipe-IT backup and disaster recovery.


#1. SnipeIT Manual Backup (Guide)

Snipe-IT provides a built-in backup feature from the web interface.

Steps:

Gui => Admin Setting => Backup => General Backup => Click Link Download

This method downloads a full backup archive including:

  • Database dump

  • Uploaded files

  • Private uploads

  • OAuth keys

  • .env configuration file

⚠ Recommended for quick manual backup before system upgrades.


#2. Backup CLI (Manual + Schedule)

For production environments, CLI backup is highly recommended.


🔹 Manual Backup Command

Run:

 
sudo -u www-data php /var/www/snipe-it/artisan backup:run

The backup file will be stored at:

 
/var/www/snipe-it/storage/app/backups

This command generates a ZIP file containing:

  • Full MySQL dump

  • public/uploads

  • storage/private_uploads

  • OAuth keys

  • .env file


🔹 Scheduled Backup (Cron Job)

To automate backups:

 
sudo crontab -e

Backup every day at 2AM:

 
0 2 * * * /usr/bin/php /var/www/snipe-it/artisan backup:run >> /var/log/snipeit-backup.log 2>&1

Quick demo – backup every 2 minutes:

 
*/2 * * * * /usr/bin/php /var/www/snipe-it/artisan backup:run >> /var/log/snipeit-backup.log 2>&1

📌 Best Practice:

  • Store backups on external storage

  • Sync to NAS or offsite location

  • Monitor log file: /var/log/snipeit-backup.log

Automation ensures your data is protected without manual effort.


#3. Restore

If your server crashes or you migrate to a new server, follow these steps.


Step 1: Identify the Backup File

List available backups:

 
ls -l /var/www/snipe-it/storage/app/backups

Example:

 
snipe-it-2025-12-01-10-36-01.zip

Create temporary restore directory:

 
mkdir /tmp/snipe-restore

Unzip backup:

 
unzip /var/www/snipe-it/storage/app/backups/snipe-it-2025-12-01-10-36-01.zip -d /tmp/snipe-restore

Locate SQL dump:

 
ls /tmp/snipe-restore/db-dumps

Example:

 
mysql-snipeit.sql

Step 2: Delete Old Database (Optional)

⚠ Only do this if performing a full restore (not migration).

Drop database:

 
mysql -u root -p -e "DROP DATABASE snipeit;"

Enter mysql root password (Previous video : Abc@1234)

Create new database:

 
mysql -u root -p -e "CREATE DATABASE snipeit CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"

Enter mysql root password (Previous video : Abc@1234)

Import database:

 
mysql -u root -p snipeit < /tmp/snipe-restore/db-dumps/mysql-snipeit.sql

Step 3: Restore Files


#1 Restore File Uploads

 
sudo cp -r /tmp/snipe-restore/public/uploads/* /var/www/snipe-it/public/uploads/

#2 Restore Private Uploads

 
sudo cp -r /tmp/snipe-restore/storage/private_uploads/* /var/www/snipe-it/storage/private_uploads/

#3 Restore OAuth Keys

 
sudo cp /tmp/snipe-restore/storage/oauth-private.key /var/www/snipe-it/storage/
sudo cp /tmp/snipe-restore/storage/oauth-public.key /var/www/snipe-it/storage/

Set proper ownership and permissions:

 
sudo chown www-data:www-data /var/www/snipe-it/storage/oauth-*.key
sudo chmod 600 /var/www/snipe-it/storage/oauth-*.key

#4 Restore the .env File

 
sudo cp /tmp/snipe-restore/.env /var/www/snipe-it/.env

Step 4: Fix Permissions + Clear Cache

Navigate to Snipe-IT directory:

 
cd /var/www/snipe-it

Fix ownership:

 
sudo chown -R www-data:www-data .

Set permissions:

 
sudo chmod -R 755 storage bootstrap/cache

Clear Laravel cache:

 
sudo php artisan config:clear
sudo php artisan cache:clear
sudo php artisan optimize

Step 5: Restart Service

 
sudo systemctl restart apache2

🚀 Final Thoughts

A proper backup strategy is the backbone of any production Snipe-IT deployment.

With:

  • Manual GUI backup

  • CLI backup

  • Cron automation

  • Full restore procedure

You now have a complete disaster recovery workflow ( SnipeIT Manual Backup).

Whether running Snipe-IT in a lab, SMB environment, or enterprise infrastructure — mastering backup and restore ensures business continuity and data integrity.

See also related articles

P13 – Ultimate QR Code SnipeIT Setup Made Easy

P13 – Ultimate QR Code SnipeIT Setup Made Easy SnipeIT – P13 QR Code Setup Guide | Create and Print Asset QR Codes Managing IT assets without proper labeling can quickly become chaotic.When devices move between departments, employees leave, or audits happen, identifying assets manually wastes time and increases errors....

Read More

P12 – Ultimate Bulk Method to Check In Check Out Assets in SnipeIT

P12 – Ultimate Bulk Method to Check In Check Out Assets in SnipeIT SnipeIT – P12 The Fastest Way to Check-In & Check-Out Assets in Snipe-IT (Bulk Method) Managing a few devices manually is easy. Managing 100–500 assets during onboarding, offboarding, or department transfers? That’s a different story. If you...

Read More

P11 – Ultimate Guide to Check In Check Out in SnipeIT

P11 – Ultimate Guide to Check In Check Out in SnipeIT SnipeIT – P11 How to Manage Check In Check Out in SnipeIT (Step-by-Step) Efficient asset tracking is the backbone of every IT department. If you cannot accurately manage Check In check Out in SnipeIT, your asset database quickly becomes...

Read More