# XAMPP Backup and Recovery

Back up, restore and transfer both XAMPP project files and MySQL databases safely.

# Backing Up a XAMPP Project

A working XAMPP project normally has two separate parts: website files inside `htdocs` and data stored in MySQL. A complete backup needs both.

## Back up project files

1. Stop active editing and save every file.
2. Locate the project folder inside `htdocs`.
3. Copy the entire project folder to an approved backup location.
4. Name the backup clearly with project and date.
5. Open the copy and confirm key PHP, CSS, JavaScript and asset files are present.

Do not use a synchronised copy as the only backup.

## Export the database

1. Start Apache and MySQL.
2. Open `http://localhost/phpmyadmin/`.
3. Select the project database.
4. Choose **Export**.
5. Use SQL format and complete the export.
6. Save the `.sql` file beside the project-file backup.

Do not treat XAMPP’s raw `mysql` storage folder as a portable database backup.

## Protect sensitive information

Use fictional data only. Check that backups and screenshots contain no real student records, personal passwords or hosted-server credentials.

## Verify the backup

A backup is not proven until it can be inspected or restored. Confirm:

- project archive opens
- expected folders and files are present
- SQL file is not empty
- SQL contains expected table definitions
- backup location is accessible from another approved device

## Check

- [ ] Project files and SQL export are both included.
- [ ] Backup name and date are clear.
- [ ] Original project still runs.
- [ ] Backup contains only fictional data.
- [ ] At least one recoverable copy exists outside the working folder.

# Restoring a XAMPP Project from Backup

Restoring a XAMPP Project from Backup recreates both the website files and the MySQL database. Work from a copy of the backup so the original remains unchanged.

## Restore project files

1. Install and test XAMPP.
2. Stop Apache and MySQL before replacing project files.
3. Copy the backed-up project folder into `htdocs`.
4. Confirm the folder contains the expected entry page and assets.
5. Start Apache and open the project through localhost.

## Restore the database

1. Start Apache and MySQL.
2. Open `http://localhost/phpmyadmin/`.
3. Create the database name expected by the project, using `utf8mb4`.
4. Select the new database and choose **Import**.
5. Choose the backed-up `.sql` file.
6. Complete the import and inspect tables and fictional records.

If the SQL export already creates and selects the database, read it before creating another database manually.

## Check configuration

Confirm the PDO connection file uses the restored database name and the local XAMPP credentials approved for class. Do not expose credentials in screenshots or public repositories.

## Verify the restoration

Test:

- public entry page
- registration with a fictional user
- login and logout
- role-protected pages
- database queries and processed outputs
- administrator CSV import with a small fictional file

A page loading is not enough; confirm that database changes persist.

## Check

- [ ] Files are inside the correct `htdocs` project folder.
- [ ] SQL import completes without unresolved errors.
- [ ] PDO connects to the restored database.
- [ ] Authentication and role checks work.
- [ ] Imported and processed data matches expected fictional results.
- [ ] Original backup remains unchanged.

# Moving a XAMPP Project to Another Computer

Moving a XAMPP project requires a verified backup of both the project files and its database.

## Prepare the source computer

1. Save all source files.
2. Export the project database as SQL through phpMyAdmin.
3. Copy the complete project folder from `htdocs`.
4. Include the SQL export and a short setup note.
5. Stop MySQL and Apache cleanly.

The setup note should record the project folder, local URL, database name and any approved port changes. Do not record real passwords.

## Transfer safely

Use an approved storage location. Keep a separate source backup until the destination has been tested. Do not email sensitive archives or use real personal data.

## Restore on the destination

1. Install and test XAMPP.
2. Copy the project folder into the destination `htdocs`.
3. Create or select the expected database.
4. Import the SQL file.
5. check the PDO connection settings.
6. Start Apache and MySQL.
7. open the project through localhost.

## Test the complete journey

Use fictional accounts and data to test registration, login, roles, protected pages, CSV import, database storage and meaningful outputs.

## Common problems

| Problem | Check |
| --- | --- |
| Page not found | Folder name and localhost URL |
| Database connection fails | Database name and PDO settings |
| Tables missing | Correct SQL file and selected database |
| Styles or images missing | Relative paths and filename case |
| Login fails | User table, complete hashes and session setup |
| Import fails | Role, form encoding, file limits and headers |

## Check

- [ ] Files and SQL were transferred.
- [ ] Source backup remains recoverable.
- [ ] Destination passes the full user journey.
- [ ] No real credentials or personal data are included.
- [ ] Configuration differences are recorded.