Data Backup and Recovery
This guide will help you understand how to backup and restore AppleAutoPro data to ensure data security.
Data Backup
AppleAutoPro provides three data backup methods: automatic backup, manual backup, and direct database export.
1. Automatic Backup
The system supports scheduled automatic backups. You can adjust the backup cycle in System Settings.
Backup File Location: Website root directory /database/backup
Automatic backup files are rotated according to the configured schedule to prevent excessive disk space usage.
2. Manual Backup (Using Commands)
If you need to create a backup immediately, you can use the following command:
For Docker deployment users, execute in the program installation directory:
docker compose exec php-fpm php think backupDb
Backup File Location: Website root directory /database/backup
Note: Backup files created this way will not be automatically rotated and require manual management.
3. Export Database
You can also directly export the MariaDB database:
For Docker deployment users, execute in the program installation directory:
docker compose exec mariadb mariadb-dump -uroot -p<database_root_password> appleautopro > apple.sql
Description:
- Replace
<database_root_password>
with your actual database password (do not include angle brackets) - The exported
apple.sql
file will be saved in the current directory - This method is suitable for complete database migration
Data Recovery
Restore from SQL File
If you have an SQL file, you can restore it using the following method:
⚠️ Warning: This operation will completely delete and rebuild the database, and all existing data will be lost. Before importing, ensure:
- Current database has been backed up
- SQL file integrity and correctness have been verified
- Recovery process has been tested in a test environment
For Docker deployment users, follow these steps:
Step 1: Copy the SQL file into the container
Place the apple.sql
file in the project root directory and execute:
docker compose cp apple.sql mariadb:/tmp
Step 2: Enter the database container
docker compose exec -it mariadb mariadb -uroot -p<database_root_password>
Replace <database_root_password>
with your actual database password (do not include angle brackets)
Step 3: Execute the following SQL commands
DROP DATABASE appleautopro;
CREATE DATABASE appleautopro;
USE appleautopro;
SOURCE /tmp/apple.sql;
Step 4: Exit and restart services
If no errors occur, execute exit
to leave the container, then restart the services:
docker compose down && docker compose up -d
Important Notes
⚠️ Important Tips:
- Regular Backups: It is recommended to backup data regularly to avoid data loss
- Offsite Storage: It is recommended to download important backup files locally or upload to cloud storage
- Test Before Recovery: Before restoring data, it is recommended to verify backup file integrity in a test environment first
- Database Password: Ensure the database password is correct when performing database operations
- Permission Issues: Ensure sufficient permissions to access backup directories and databases