MySQL · Backup · System Admin

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.

⏱ 15 min📊 Intermediate📅 May 18, 2024🔄 Updated April 2026

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.

★ CoreConduit Inventory users: The examples below use 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/

Backup and Restore Your Database

Export A Database

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

Backup your Inventory Management System

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.

Import

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

WARNING! You are about to permanently delete ALL of your data.
DROP DATABASE oswa_inv;

CREATE DATABASE oswa_inv;

source /path/to/oswa_inv.sql

Exit mysql.

Migrating from OSWA-Inv to CoreConduit Inventory v3.5

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:

  • Database name: OSWA-Inv uses oswa_inv; CoreConduit uses inventory
  • App user: CoreConduit uses a dedicated webuser with limited privileges instead of root
  • Schema additions: CoreConduit adds tables for orders, audit trails, and role-based access — your existing product and category data maps directly

Migration 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 →

Did this guide help?

Your answers shape what we write next.

How to Reset Your Password

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.

Step One—Shut Down MySQL

In terminal, stop the MySQL process:

sudo systemctl stop mysql
★ Updated: Modern Debian/Ubuntu systems (Raspberry Pi OS Bookworm+) use systemctl instead of the older /etc/init.d/ style. The original command still works via compatibility layer, but systemctl is the current standard.

Step Two—Access MySQL Safe Mode

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

Step Three—Set Up a New Password

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.

Automated Daily Backups (Optional)

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 -
★ 2024 Insight: The 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.
← Back to Guides

Join the conversation.

Questions, experiences, or ideas — we're listening.