Lesson 2.6: Resetting the lab between sessions
After a course, the training sites are full of half-finished articles, test users and changed settings. The next
group needs a clean start. With SQLite and exp:install a reset takes minutes, but it also deletes everything, so it
must never be pointed at a site that matters. This lesson teaches a safe routine.
Warning
A reinstall with --force replaces the database and the settings of the installation. Only ever run it in a
directory that you created for training.
At a glance
| Course | Train the trainer |
| Module | Module 2: Building the training lab |
| Duration | 35 minutes (10 presenting, 25 exercise) |
| Level | Intermediate |
| Audience | Trainers who run repeated courses |
| Prerequisites | Lesson 2.3 |
Learning objectives
After this lesson, learners can:
- decide between a full reinstall and a restore of a saved database file;
- run
exp:install --dry-runand then--forceon a training directory; - save and restore a "golden" copy of a training database;
- remove training accounts from a shared site.
Trainer's notes
How to present it
- Two strategies (4 minutes):
- Reinstall:
exp:install --forcereplaces the database (with the default--db-action=remove) and the settings. Clean, always the same, takes as long as an install. - Golden copy: install once, prepare the state you want (sample content, learner accounts), stop the server
and copy
var/storage/sqlite3/exponential.dbandvar/storage/aside. To reset, stop the server, copy them back and clear the caches.
- Reinstall:
- Show the safety net (3 minutes): without
--forcethe command refuses an existing installation. Always run--dry-runfirst; it works on an existing installation without--force. - Explain the caches (3 minutes): after a restore, clear them with
php bin/php/ezcache.php --clear-all.
Common questions
Does a reinstall keep my learners' accounts? No. Everything in the database is replaced. Create accounts again, or use the golden copy.
What about uploaded images? They are files under var/ (the site's storage directory), not in the database.
Copy the storage directory with the database when you keep a golden copy.
Pitfalls
- The wrong directory. Check
pwdbefore every--force. - The server still running. Stop the server before copying an SQLite file, or the copy may be inconsistent.
- Caches. A restored database with old caches shows old pages. Clear all caches after a restore.
Hands-on exercise
On the training installation from lesson 2.3:
- Stop the server:
php bin/php/console exp:velocity stop. - Make a golden copy:
mkdir -p ../goldenandcp -a var/storage ../golden/. - Start the server, sign in and create one test article anywhere (any title).
- Stop the server. Restore:
cp -a ../golden/storage/. var/storage/. - Clear the caches:
php bin/php/ezcache.php --clear-all. - Start the server and check that the test article is gone.
- Now test a full reinstall:
pwd(check the directory!), thenphp bin/php/console exp:install --dry-run --url=http://127.0.0.1:8087. - If the dry run passes:
php bin/php/console exp:install --apply --force --url=http://127.0.0.1:8087and note the new generated password.
Expected result
- After the restore, the test article no longer exists.
- After the reinstall, the site is the fresh
sevenx_multisitesite with a new administrator password, andvar/log/initial-admin-passwordexists again. - The trainer adds the reset routine and its duration to the course checklist.
Quiz
- What does
exp:install --forcereplace? - Why stop the server before copying an SQLite database file?
- What must you run after restoring a database file?
- Does
--dry-runneed--forceon an existing installation?
Answers
- The database (with the default
--db-action=remove) and the settings of the installation. - The server may be writing to the file; a copy made then can be inconsistent.
- Clear the caches:
php bin/php/ezcache.php --clear-all(Caches). - No. A dry run works without
--forceand changes nothing.
Further reading
- The console install:
--force,--dry-runand--db-action. - Caches: what the caches are and how to clear them.
- Live demo safety: preparing a clean demo installation.
Related pages
- Module 2: Building the training lab
- Train the trainer: course overview
- Trainers: start here
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.