Day-to-day operations
Scheduled jobs, backups, upgrades and monitoring.
Scripts you may need
| Script | Does |
|---|---|
scripts/migrate.php | Creates the tables, or applies new upgrades to an existing database. |
scripts/make-key.php | Adds APP_KEY to .env once. |
scripts/create-organisation.php "Name" email | Creates an organisation and its first administrator (prints an invitation link). |
scripts/reset-two-factor.php email | Removes two-step sign-in for a login: for a locked-out administrator who has lost their phone and recovery codes. |
scripts/reinvite.php email | Prints a new one-time invitation link for a login: for a locked-out administrator. |
scripts/export-old-systems.php | Reads an older Staff, People or Team service database (read only) and writes an import file. |
scripts/import.php | Checks (or, with --commit, performs) an import. See Importing data. |
scripts/backup.php [--keep=14] [--to=DIR] | Backs up the database and storage/uploads/ to storage/backups/, with checksums and a manifest. |
scripts/restore-check.php FILE --into=SCRATCH_DB | Proves a backup restores: loads it into a scratch database and compares every table's rows and the files with the manifest. Never touches the live database. |
scripts/deliver-events.php | Sends queued webhooks. |
scripts/reconcile.php [--fix] | Consistency check. |
scripts/demo-reset.php | Rebuilds the demo (demo installations only). |
Scheduled jobs
| Job | How often | Why |
|---|---|---|
php scripts/deliver-events.php | Every minute | Sends queued webhooks and retries failures. Without it events wait safely in the outbox. |
php scripts/reconcile.php [--fix] | Nightly | Runs the consistency check and (with --fix) puts right what can be put right. |
php scripts/demo-reset.php | Nightly, demo installations only | Wipes and reseeds the demo. It refuses to run unless DEMO_MODE is on and the database name contains “demo”. |
* * * * * php /path/to/care-core/scripts/deliver-events.php >> /path/to/care-core/storage/deliver.log 2>&1
15 3 * * * php /path/to/care-core/scripts/reconcile.php --fix >> /path/to/care-core/storage/reconcile.log 2>&1
Nothing needs to run for a leaver’s access to end on the right day: that is checked on every request.
Avoid overlapping runs. If your host runs jobs every minute, use a lock (
flock -n /tmp/cc.lock …) for anything slow, and never schedule the demo reset every minute.Backups
- Run
php scripts/backup.phpdaily from cron (for examplesh -c 'cd /path/to/care-core && php scripts/backup.php --keep=14'). It writes the database and the uploaded files tostorage/backups/, which is blocked from the web, and keeps the last 14. - Copy the backups off the server. A backup on the same server is lost with the server. Care Core does not do this for you.
- Prove a backup restores: create an empty scratch database and run
php scripts/restore-check.php storage/backups/FILE.sql.gz --into=SCRATCH_DB(the scratch name must contain “restore” or “test”). - The backup includes
storage/uploads/, where photos and signatures live. - Keep a copy of
.envand especiallyAPP_KEYsomewhere separate from the database backups. Without the key, the encrypted National Insurance and bank details cannot be read.
Upgrading
- Back up the database and
storage/. - Get the new code (for example
git pull). - Run
php scripts/migrate.php. On an existing database it applies each numbered file indatabase/migrations/that has not been applied, once, in order, and drops nothing. It prints what it applied, or “Nothing to apply”. - Check the sign-in page and the dashboard.
Never run migrate.php --fresh on a database with real data: it drops every table. It refuses unless the database name contains “test” or “demo” (or demo mode is on).
Monitoring
- Webhooks: Admin › Integrations shows delivered counts and “waiting or failed” for each address. A growing failed count means a receiver is down or rejecting.
- Consistency: check the dashboard’s “Needs attention” or the nightly reconcile log. It should be quiet.
- SCIM: each token shows when it was last used. A token that has not been used for a long time may mean provisioning has stopped.
- Disk:
storage/grows slowly with photos and signatures. - Expiring secrets: the Entra client secret and any SCIM token you set to expire.
- Logs: with
APP_DEBUG=falseerrors are written to your server’s PHP error log, not shown to users.
Security maintenance
- Keep PHP, MySQL and the server operating system patched.
- Limit who can reach the database and the server; use strong, unique credentials.
- Review administrator logins from time to time on Admin › Logins.
- Rotate the Entra client secret before it expires, and revoke SCIM tokens you no longer use.
Moving to another server
- Copy the code, the database,
storage/uploads/, and.env(including the sameAPP_KEY). - Update
APP_URL, and the redirect address in Entra, and the SCIM address in Entra if the address changed. - Re-create the scheduled jobs.