Demo All names and records here are made up, and the data resets every night. Please do not enter real personal information. ← Back to Find Care Scotland software · All software
Care Core

Documentation › Running it › Day-to-day operations

Day-to-day operations

Scheduled jobs, backups, upgrades and monitoring.

Scripts you may need

ScriptDoes
scripts/migrate.phpCreates the tables, or applies new upgrades to an existing database.
scripts/make-key.phpAdds APP_KEY to .env once.
scripts/create-organisation.php "Name" emailCreates an organisation and its first administrator (prints an invitation link).
scripts/reset-two-factor.php emailRemoves two-step sign-in for a login: for a locked-out administrator who has lost their phone and recovery codes.
scripts/reinvite.php emailPrints a new one-time invitation link for a login: for a locked-out administrator.
scripts/export-old-systems.phpReads an older Staff, People or Team service database (read only) and writes an import file.
scripts/import.phpChecks (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_DBProves 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.phpSends queued webhooks.
scripts/reconcile.php [--fix]Consistency check.
scripts/demo-reset.phpRebuilds the demo (demo installations only).

Scheduled jobs

JobHow oftenWhy
php scripts/deliver-events.phpEvery minuteSends queued webhooks and retries failures. Without it events wait safely in the outbox.
php scripts/reconcile.php [--fix]NightlyRuns the consistency check and (with --fix) puts right what can be put right.
php scripts/demo-reset.phpNightly, demo installations onlyWipes 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.php daily from cron (for example sh -c 'cd /path/to/care-core && php scripts/backup.php --keep=14'). It writes the database and the uploaded files to storage/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 .env and especially APP_KEY somewhere separate from the database backups. Without the key, the encrypted National Insurance and bank details cannot be read.

Upgrading

  1. Back up the database and storage/.
  2. Get the new code (for example git pull).
  3. Run php scripts/migrate.php. On an existing database it applies each numbered file in database/migrations/ that has not been applied, once, in order, and drops nothing. It prints what it applied, or “Nothing to apply”.
  4. 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=false errors 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

  1. Copy the code, the database, storage/uploads/, and .env (including the same APP_KEY).
  2. Update APP_URL, and the redirect address in Entra, and the SCIM address in Entra if the address changed.
  3. Re-create the scheduled jobs.