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

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

In this tutorial, you will learn how to perform a full Snipe-IT backup on Ubuntu, including both files and database.
We walk through manual backup commands, helping you understand exactly what needs to be backed up and why.
You will also learn how to automate Snipe-IT backups using cron jobs, ensuring your data is protected without manual effort.
This guide explains best practices for secure backup storage and permission handling on Linux systems.
In addition, we demonstrate how to restore Snipe-IT from a backup in case of system failure or server migration.
Whether you are running Snipe-IT in production or testing environments, this tutorial is easy to follow and practical.
The steps are suitable for Ubuntu Server 20.04, 22.04, and newer versions.
By the end of this guide, you’ll be confident in managing Snipe-IT backup, scheduling, and disaster recovery.

#1. Backup Gui (Manual)

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

#2. Backup CLI (Manual + Schedule)


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

The path to the backup file is:
/var/www/snipe-it/storage/app/backups

Scheduled backup
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

#3. Restore

Step 1: Identify the backup file

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

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

Unzip the backup file
mkdir /tmp/snipe-restore

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

Find the SQL file:
ls /tmp/snipe-restore/db-dumps

Ex: mysql-snipeit.sql

Step 2: Delete the old database (option)


Do this only if you want to restore full (not migrate)

mysql -u root -p -e “DROP DATABASE snipeit;”

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

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

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

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

Step 3: Restore files

#1: Restore file uploads
Backup contains the public/uploads/* folder, you just need to copy it back to the real folder:
sudo cp -r /tmp/snipe-restore/public/uploads/* /var/www/snipe-it/public/uploads/

#2 Restore

storage/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/

Decentralization:
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

cd /var/www/snipe-it

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

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 the service

sudo systemctl restart apache2