How To Backup and Restore your Inventory Management System
Complete guide to backing up files and MySQL databases for OSWA-Inv. Export, import, and password recovery procedures.
Complete guide to backing up files and MySQL databases for OSWA-Inv. Export, import, and password recovery procedures.
There are two important sections of The Inventory Management System that need to be backup and/or restore. The system stores images that are uploaded in a directory within the source-code. Backup this directory or the entire application to a folder on your file system.
oswa_inv (the original OSWA-Inv database name). If you're running the CoreConduit Inventory System, your database is named inventory and your app user is webuser — substitute accordingly. The automated script at the bottom already uses the correct values.
Example:
sudo cp -R /var/www/html/warehouse-inventory-system /home/pi/Downloads/
To Export a database, open up terminal, making sure that you are not logged into MySQL and type:
mysqldump -u [username] -p [database name] > [database name].sql
mysqldump -u'root' -p'password' oswa_inv > /path/to/oswa_inv.sql
The database that selected in the command will now be exported to a file.
Log into mysql command-line interface:
mysql -u'username' -p'password'
If you are having difficulty logging into mysql please see the section below, How to Reset Your Password
DROP DATABASE oswa_inv; CREATE DATABASE oswa_inv; source /path/to/oswa_inv.sql
Exit mysql.
If you're upgrading from OSWA-Inv to the CoreConduit Inventory System, your data migrates cleanly — the schema builds on the same foundation. Key differences to account for:
oswa_inv; CoreConduit uses inventorywebuser with limited privileges instead of rootMigration path: dump your oswa_inv database with the commands above, then follow the import section in the CoreConduit deployment guide — it includes schema migration scripts that handle the table differences.
CoreConduit Inventory System — Complete Deployment Guide →
Your answers shape what we write next.
When you first install MySQL, you have to set up your root password. However, should you forget it at any point, you can still recover it.
In terminal, stop the MySQL process:
sudo systemctl stop mysql
systemctl instead of the older /etc/init.d/ style. The original command still works via compatibility layer, but systemctl is the current standard.
In safe mode, you will be able to make changes within the MySQL system with a root password alone, without the need for MySQL root password.
sudo mysqld_safe --skip-grant-tables &
Once safe mode has started up, log into MySQL and when prompted, use your standard root password.
mysql -u root
Finally, set up the new MySQL root password by typing the command below. Replace "newpassword" with the password of your choice.
-- For MySQL 8.0+ (default on Raspberry Pi OS Bullseye/Bookworm):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
-- For older MySQL/MariaDB versions:
-- update user set password=PASSWORD("newpassword") where User='root';
Be sure to reload everything:
FLUSH PRIVILEGES;
And you now have a new root password.
For production use, consider setting up automated daily backups with a cron job:
# Create backup script sudo tee /usr/local/bin/backup-inventory.sh << 'EOF' #!/bin/bash DATE=$(date +%Y%m%d_%H%M%S) BACKUP_DIR="/home/pi/backups" mkdir -p $BACKUP_DIR # Backup database mysqldump -u'webuser' -p'yourpassword' inventory > "$BACKUP_DIR/inventory_$DATE.sql" # Backup files (excluding uploads if they're large) tar -czf "$BACKUP_DIR/inventory_files_$DATE.tar.gz" -C /var/www/html inventory # Keep only last 7 days of backups find $BACKUP_DIR -name "inventory_*.sql" -mtime +7 -delete find $BACKUP_DIR -name "inventory_*.tar.gz" -mtime +7 -delete EOF sudo chmod +x /usr/local/bin/backup-inventory.sh # Add to cron (runs daily at 3 AM) echo "0 3 * * * /usr/local/bin/backup-inventory.sh" | sudo crontab -
PASSWORD() function shown in the original article was deprecated in MySQL 8.0 (2018) and removed entirely in newer versions. Always use ALTER USER ... IDENTIFIED BY for password changes on modern systems. Also consider storing backups off-device (USB drive, NAS, or cloud) for disaster recovery.
Questions, experiences, or ideas — we're listening.