Skip to content

Migrating from OSCAR19

Michael Yingbull edited this page Sep 30, 2026 · 1 revision

Migrate from OSCAR19 to CARLOS

Home / Technical documentation / Running CARLOS

Use this walkthrough when you have already copied an OSCAR19 (O19) database backup, its documents, and its deployed oscar.properties file onto a new CARLOS server. It takes you through checking those files, assessing the migration, importing with the built-in carlos-ctl tools, reviewing the result, and opening CARLOS for clinic use.

This procedure is for the Debian package installation on Ubuntu, with a fresh CARLOS database that has never been used clinically. You need a server administrator account with sudo access and someone who can review the clinic's records, permissions, and integrations. Run the commands in a Bash terminal on the new CARLOS server, unless a step explicitly names another machine. Absolute paths are used, so your working directory does not matter.

Experimental feature: carlos-ctl import-o19 is labelled experimental. Rehearse the complete import and recovery on a separate, protected copy before the final cutover. A successful command needs both technical and clinic review before the migrated system is used for care.

Version checked: CARLOS 2026.08.0-alpha18 and carlos-ctl 1.1.1, reviewed against their source on 2026-09-29. This is a source-verified procedure; it has not been run against your server or your backups. The release operator procedure and the installed man carlos-ctl are the detailed references. Podman installations have different paths and host commands; use their deployment's migration instructions.

On this page: What the tools do · Prepare the server · Check the backups · Source digests · Assessment · Dry run · Import · Settings · Validation · Cutover and cleanup · Resume and rollback · Troubleshooting

What the tools do

The importer restores the old database into a temporary database called o19_import, checks it, and copies and transforms its data into the database configured for CARLOS. It restores the documents into CARLOS's document store and generates a proposed configuration fragment. You do not manually load the O19 dump into the live CARLOS database or replace CARLOS's configuration with the old file.

Tool or stage What it does What you must review
o19-preflight Restores the dump into staging and reports whether the clinic can be migrated. Blockers, requested acknowledgements, and limitations of the assessment.
import-o19 --dry-run Also checks that the CARLOS target is a stock installation and previews translated settings. The reported verdict and proposed settings; this does not rehearse the data copy or document restore.
import-o19 Takes a pre-import backup, stages and assesses the source, copies data, restores documents, translates settings, and verifies the result. The final validation report, access changes, documents, and clinic workflows.
Manual configuration review You apply approved lines from the generated fragment. Paths, integrations, credentials, and changes from O19 defaults.
import-o19 --resume Continues an interrupted real import using its recorded progress. The named failure and its remedy; preserve the original inputs and workspace.
import-o19 --cleanup Removes temporary staging data after verification and retires the run's reports. Retain the reports and archive export before considering the migration complete.

The temporary database is separate from the configured CARLOS database, whose name is recorded in /etc/carlos-emr/carlos-emr.env. A database named oscar is not necessarily the old server's database: older CARLOS installations can use that name too. Let carlos-ctl read the target configuration.

Data that is preserved outside the application

Some O19 features have no CARLOS equivalent. Preservation means you can recover the underlying data; it does not mean staff can open it in CARLOS.

Source material Result
Supported clinical and administrative tables Copied or merged into the live CARLOS schema according to the installed migration rules.
Removed-module or unknown tables Preserved in o19_archive and as import_archived_<table> tables in the CARLOS database.
Removed or unknown columns Preserved in import_archived_<column> columns and in an archive copy.
Reference data supplied by CARLOS CARLOS's reference rows remain live; the clinic's source rows are archived.
Tables that combine CARLOS seed data with clinic data CARLOS wins on a shared natural key; additional eligible clinic rows are merged, sometimes with new IDs. The complete source table is archived.

Review the report for clinic-specific encounter templates, fees, lookup lists, and other customizations affected by that merge policy. Archive-only material can include deprecated antenatal forms, generic intake, OCAN, eyeform, drug dispensing, CAISI beds/rooms, PHR material, Integrator consents, report-runner templates, and OLIS preferences. The assessment identifies which affected tables actually contain your clinic's data. Neither the archive schema nor the import_archived_ objects has an application screen, report, or API.

1. Prepare the new server

  1. Finish the package installation with the correct billing province and no demonstration data. The checked release supports Ontario (on) and British Columbia (bc) migration profiles. The source clinic and target province must agree; --province cannot change an already configured target.
  2. Keep the target unused. Do not sign in, create patients, add staff, or customize database records before importing. The importer requires the stock seeded database and refuses a used or demonstration database without an override. The package's normal initial application startup is accounted for by the importer.
  3. Keep the server restricted to the migration team during rehearsal and review. Arrange how outbound fax, email, billing, laboratory, and other integrations will be isolated on the rehearsal server, and which server will own them at cutover.
  4. Check the installed packages and commands:
dpkg-query -W carlos-emr carlos-ctl
sudo carlos-ctl import-o19 --help
sudo carlos-ctl o19-preflight --help
sudo carlos-ctl db-info
sudo carlos-ctl db-validate
sudo carlos-ctl check

From CARLOS alpha16 onward, carlos-ctl is a separate package. Install the CLI package supplied on the chosen CARLOS release page; its version number is independent of CARLOS's. The application package supplies the schema and import manifests. Resolve missing commands, manifest errors, incomplete provisioning, or schema validation failures before proceeding. On a fresh installation with unapplied schema migrations, follow the installation diagnosis and run sudo carlos-ctl db-migrate as directed.

Check the target's configured province and database name without displaying the rest of its configuration:

sudo rg '^(CARLOS_PROVINCE|CARLOS_DB_NAME)=' /etc/carlos-emr/carlos-emr.env

If rg is not installed on the server, use sudo grep -E '^(CARLOS_PROVINCE|CARLOS_DB_NAME)=' /etc/carlos-emr/carlos-emr.env instead. A province mismatch needs a correctly provisioned target.

Allow enough space and prepare recovery

The database volume needs approximately 2.5 times the uncompressed SQL dump size free for staging, the target copy, and archives. The files volume also needs room for extraction and restoration: budget twice the expanded documents archive, plus twice the bundle size if using a bundle. Backups and the original input files need additional space. When these directories share a filesystem, their requirements accumulate. The importer performs its own capacity checks and reports the volume that needs more space.

Use these read-only checks to find MariaDB's actual data directory and the available space. Run df -h on the returned data-directory path too if it is on a separate volume:

sudo mariadb -N -e 'SELECT @@datadir, VERSION();'
df -h /var/lib/carlos-emr /srv

The importer requires MariaDB 10.5 or newer and refuses a server with attached replicas because its bulk copy disables binary logging. Use the supported packaged database setup. Do not plan to recover this import by replaying its binary logs.

Configure backups and recovery, retain the restic repository password, and rehearse restoring the target. Then stop CARLOS and take and verify a backup of the unused target:

sudo carlos-ctl stop
sudo systemctl is-active carlos-emr
sudo carlos-ctl backup full
sudo carlos-ctl backup verify
sudo carlos-ctl backup snapshots

is-active should report inactive; its nonzero exit status for an inactive service is expected. Check each backup command's result and record the database and files snapshot IDs and their times. The real import also takes its own pre-import backup before staging the dump. Keep CARLOS stopped through assessment, import, and configuration review.

Keep the original O19 backups separately from the target's recovery backup. The original O19 server is the fallback for the clinic, while the pre-import CARLOS backup lets you rebuild the unused target. These serve different recovery needs.

2. Check the three backups

The examples below assume these filenames. Substitute the actual absolute paths on your server in every command; these are examples, not detected files:

Input Example path Required contents
Database /srv/migration/o19.sql.gz A complete logical mysqldump export of one O19 database, as .sql or .sql.gz.
Documents /srv/migration/o19-documents.tar.gz A .tar or .tar.gz containing one O19 context directory, including documents, eForm images, and HRM files where used.
Configuration /srv/migration/oscar.properties The file actually used by the old clinic installation.
Optional source digests /srv/migration/o19-digests.json Table content hashes generated from the same source state as the dump; see the next step.

Store these in a directory restricted to the migration operator/root. They contain patient data and credentials. Keep an untouched copy. Confirm that the database and documents describe the same backup point and that the properties belong to that clinic. Existing historical backups are suitable for rehearsal; the final cutover needs a final consistent export after O19 and other writers stop. O19 commonly uses MyISAM tables, for which --single-transaction alone does not make a live dump consistent.

For the compressed examples, check that gzip can read the SQL and tar can read the document archive:

sudo ls -lh /srv/migration/o19.sql.gz /srv/migration/o19-documents.tar.gz /srv/migration/oscar.properties
sudo gzip -t /srv/migration/o19.sql.gz
sudo tar -tzf /srv/migration/o19-documents.tar.gz > /dev/null

Successful integrity checks normally print nothing. A nonzero exit or an error needs investigation before import. For plain .sql, omit the gzip check; for a plain .tar, use tar -tf. These checks establish that the files can be read, not that the source export was complete or internally consistent. Compare any checksums supplied by the source operator. A checksum calculated only after arrival cannot prove what was originally sent.

Database backup format

--dump does not accept a MariaDB/MySQL data directory, .ibd files, a physical backup, or an arbitrary backup container. Recover those into an isolated compatible database first and produce the logical export described in the release export recipe.

The importer refuses dumps that choose their own database with USE or CREATE DATABASE, such as mysqldump --databases or --all-databases output. It also checks for the completion trailer, unsupported collations, and unsuitable GTID directives. A compatible export names the single database as the positional argument, omits triggers, excludes views as identified by source preflight, and uses --set-gtid-purged=OFF when exporting from MySQL 5.6 or later. If the existing dump fails these checks, obtain a corrected export from the source or from an isolated recovery of that backup. Preserve the original file for diagnosis.

Document archive layout

Privately inspect the archive listing before importing; names can contain patient identifiers:

sudo tar -tzf /srv/migration/o19-documents.tar.gz | less

Press q to leave less. The archive should have one top-level context directory, often oscar, oscar_mcmaster, or the old database name. A typical layout is:

oscar/
oscar/document/
oscar/document/example.pdf
oscar/eform/
oscar/eform/images/
oscar/eform/images/example.png
oscar/hrm/

Only directories your clinic uses need to exist. An archive starting at var/lib/OscarDocument/..., containing several contexts, or containing loose document/ and eform/ directories at its root has the wrong layout. Links and special files are also refused. Resolve linked storage to actual files in the prepared backup; renaming a ZIP file to .tar.gz does not convert it.

If the documents backup is already an extracted directory on the new server, create a tar from its parent. For example, if the recovered context is /srv/migration/recovered/OscarDocument/oscar, run the following only when the output filename does not already exist:

sudo sh -c 'umask 077; tar -C /srv/migration/recovered/OscarDocument -czf /srv/migration/o19-documents.tar.gz oscar'
sudo tar -tzf /srv/migration/o19-documents.tar.gz > /dev/null

Replace oscar with the recovered context's real directory name. Include the complete context, including images and HRM reports, rather than just scanned PDFs. The importer renames the context to carlos, restores it under /var/lib/carlos-emr/CarlosDocument/carlos/, assigns application ownership, and checks database references against the files. HRM reports are relocated into document/ and their database paths updated; conflicting filenames are reported rather than overwritten.

3. Decide how to verify the source backup

There are two distinct checks:

  • A file checksum establishes whether a backup file matches a known original file.
  • Source content digests establish whether the database restored on CARLOS contains the table values measured on O19 before export.

If o19-digests.json was supplied with the backup, add --o19-digests /srv/migration/o19-digests.json to each assessment, dry-run, and import command below. It must come from the same frozen source state and a compatible assessment-script version. A digest generated from today's changed O19 database cannot validate an older backup.

When you have only the three backups

You can assess and preview those backups without a digest file. The reports will describe source-content verification as unavailable. To perform the real import in that situation, the responsible operator must explicitly acknowledge this gap using:

--accept no-content-digests

The real-import example below includes that flag because it starts with only the three backups. Keep it only after reviewing and accepting the limitation. This does not disable verification between staging and the migrated CARLOS data; it means the importer cannot independently prove that the backup contains the original source database's values. Generating hashes from the same restored dump would not establish that missing link.

If the original frozen source state is still available, obtain digests instead. On the new CARLOS server, generate the standalone assessment script from the installed manifests:

sudo carlos-ctl o19-preflight --write-standalone /srv/migration/o19_preflight.py

Transfer that script securely to the O19 server. There, with a database account that can read the whole source schema, run a source assessment such as:

sudo python3 /srv/o19-export/o19_preflight.py \
  --db oscar --province on --mysql-cmd mysql \
  --mysql-arg=-uroot --mysql-password-file /root/.o19pw \
  --properties /srv/o19-export/oscar.properties \
  --json /srv/o19-export/preflight.json \
  --digests /srv/o19-export/o19-digests.json

Replace the database, province, and paths with the source's values. /root/.o19pw means an existing root-only file containing that database account's password; do not put the password in command history. Use bc for British Columbia. Review errors in individual table hashing as well as the assessment verdict, then transfer the digest file securely to the new server. Regenerate the standalone script after changing the target CARLOS package. The source assessment reference explains account privileges and other authentication options.

4. Assess the backup

Run this on the new CARLOS server, with CARLOS stopped. It creates or reuses the staging database and writes reports, but does not copy records into the CARLOS application database:

sudo carlos-ctl o19-preflight \
  --dump /srv/migration/o19.sql.gz \
  --properties /srv/migration/oscar.properties
assessment_rc=$?
printf 'Assessment exit status: %s\n' "$assessment_rc"

Add the digest option here if available. The separate-file assessment does not accept --documents; the actual document restore and reconciliation happen during the real import. A large SQL restore can take considerable time. Keep your SSH session stable or use your site's usual persistent terminal session.

Open the resulting report on the server:

sudo less /var/lib/carlos-emr/o19-import/preflight.txt
Assessment exit Meaning Next action
0 Go under the checks performed. Read advisories, source-content verification, and NOT MEASURED HERE before continuing.
1 Go with acknowledgements. Review the listed changes with the clinic; record each approved --accept class.
2 No-go. Resolve the named blockers before migration.
3 Tool failure. Correct file, database, capacity, argument, or other execution errors and repeat the assessment.

LDAP authentication, password-protected case-management notes, unsupported provinces, missing required clinic/facility data, and some encoding problems require remediation. An --accept option cannot override every failure. Neither preflight nor a dry run tests all target column widths, numeric conversions, or document references; a full rehearsal is needed to find problems in those later phases.

Review requested acknowledgements

An acknowledgement records a decision with consequences for the clinic's data or verification. Add only the classes named by your assessment or failure report that the responsible reviewers have approved. For example, --accept archived-forms --accept dropped-columns accepts those two findings. Do not paste every option into the command.

Class Decision being recorded
archived-forms Data from removed form/modules will be preserved without a CARLOS screen.
unknown-as-archive Unrecognized tables or columns will be preserved for later access rather than made usable automatically.
dropped-columns Populated columns without a CARLOS equivalent will be preserved as archived columns.
charset-repair The importer may repair detected double-encoded text during the copy.
olis-gone The old clinic used OLIS; CARLOS has no OLIS module.
carry-credentials Live OAuth secrets or signing keys in the database will be copied; their continued use needs review.
no-content-digests Original-source content could not be fully verified.
unverified-bundle A bundle lacks an independently supplied checksum. Relevant only to bundle input.
no-documents Used with --skip-documents to omit documents. This does not produce the complete clinic migration described here.
no-pre-backup There may be no automatic pre-import recovery snapshot. Resolve backup setup for this walkthrough.
content-transfer Staging disagrees with supplied source digests. Investigate the dump, source state, and restore before considering acceptance.
content-migration Migrated or preserved values disagree with the expected values. Investigate the named records before considering acceptance.

o19-preflight only accepts assessment classes and the bundle acknowledgement: the first six rows and unverified-bundle. The remaining decisions belong to the import phases. Assessment and dry-run acknowledgements are not saved as approval for the real import; include the approved flags again on the real command.

5. Preview the import and settings

Use the same source files to check the stock target and generate the proposed properties. No administrator name is needed for this preview:

sudo carlos-ctl import-o19 --dry-run \
  --dump /srv/migration/o19.sql.gz \
  --documents /srv/migration/o19-documents.tar.gz \
  --properties /srv/migration/oscar.properties

Add the digest option if supplied and any approved assessment flags. Read both the verdict and the settings report:

sudo less /var/lib/carlos-emr/o19-import/preflight.txt
sudo less /var/lib/carlos-emr/o19-import/report.txt
sudo less /var/lib/carlos-emr/o19-import/o19-derived-carlos.properties.dry-run

A dry-run exit of 0 means the preview finished. It can still report a no-go verdict or content-transfer problems. Read the reports. It does not perform the data copy, restore or reconcile documents, run final verification, or take the real import's recovery snapshot.

The .dry-run fragment can contain credentials. Review it privately and resolve missing or unsuitable settings; use the regenerated fragment from the real import when applying configuration. The staging data left by assessment/dry run can be reused. Start the real import without --resume if these are the only operations you have run.

6. Run the import

For the final migration, confirm that these are the final synchronized backups and that O19 and all source writers remain stopped. If O19 was still receiving work during rehearsal, repeat the tested process on a fresh target using the final backups. import-o19 is a one-time import into an unused target; it is not an incremental synchronization tool.

Choose a unique emergency administrator name, such as MigrationAdmin. It must contain 1–30 letters or digits, with no spaces or punctuation, must not be carlosdoc, and must not already exist in the source. The importer creates this account before removing the seeded account.

Ensure CARLOS is still stopped, then run the command. This example is for the three backups without source digests, after accepting that limitation in step 3:

sudo carlos-ctl stop
sudo carlos-ctl import-o19 \
  --dump /srv/migration/o19.sql.gz \
  --documents /srv/migration/o19-documents.tar.gz \
  --properties /srv/migration/oscar.properties \
  --admin-user MigrationAdmin \
  --accept no-content-digests
import_rc=$?
printf 'Import exit status: %s\n' "$import_rc"

If you have valid source digests, replace --accept no-content-digests with --o19-digests /srv/migration/o19-digests.json. Append any other specifically approved acknowledgements. If review found a custom role needs a particular stock-role template, the repeatable option is, for example, --role-template 'Clinic Physician=doctor'; use the actual role name and an approved mapping.

Keep the exact input files, installed package versions, and command choices throughout the run. Do not change packages, rename the target database, start another import, or start the application while it is in progress.

The phases run in this order: target checks → pre-import backup → staged restore → assessment/content check → data copy → documents and archive export → properties translation → final verification. The log labels the backup P3, even though it runs before P1 staging. Reusing an already staged identical dump is expected.

You can follow progress from a second terminal:

sudo tail -f /var/lib/carlos-emr/o19-import/report.txt

Use Ctrl+C in that second terminal to stop following the log. Leave the terminal running the import alone. While an import is in progress, the service guard also prevents application starts after a reboot or a separate start request.

For a normal import invocation, 0 means completion and 1 means a refusal or failure. On failure, keep the workspace and use resume or rollback; do not sign in to inspect a partially migrated database. On success, confirm the validation report explicitly records passed verification:

sudo less /var/lib/carlos-emr/o19-import/import-report.txt

7. Review and apply the translated settings

The importer does not modify the deployed carlos.properties file automatically. Keep CARLOS stopped while reviewing the final fragment and phase report:

sudo less /var/lib/carlos-emr/o19-import/o19-derived-carlos.properties
sudo less /var/lib/carlos-emr/o19-import/report.txt

The translation compares O19 settings with its stock defaults and the installed CARLOS property map:

Report category What to do
carry / carry-secret Review the proposed setting. Secret values are in the private fragment, even when masked in the report; verify or rotate the applicable credentials.
Translated paths or endpoints Confirm document paths use the new CARLOS store and DrugRef uses this deployment's endpoint. Investigate paths the translator could not recognize.
carlos-default The old value matched an O19 default, and CARLOS's default differs. Decide whether to accept CARLOS's behavior or explicitly retain the old preference.
Deployment-owned settings Keep this server's generated database connection, server configuration, and deployment secrets.
Removed feature settings Review the named feature loss; copying its old switch does not restore the feature.
unknown, needs-review, or refused settings Determine the correct CARLOS equivalent or resolution before enabling the affected workflow.

Review fax, email, laboratory/HRM connections, MCEDT or Teleplan, HCV, external URLs, signatures, printing, label calibration, and any clinic-specific paths. A carried setting does not establish that an external service is configured, reachable, authorized, or ready to switch servers. Use the properties reference and integrations guide for the affected features.

Save a private copy of the new server's existing settings, then edit the deployed file. The first command deliberately refuses to overwrite an existing saved copy; keep that original if repeating this step:

sudo sh -c 'set -C; umask 077; cat /etc/carlos-emr/carlos.properties > /etc/carlos-emr/carlos.properties.before-o19'
sudoedit /etc/carlos-emr/carlos.properties

Append only the approved lines from the final fragment. Review any duplicate keys deliberately: Java properties use the last value. Preserve the generated database credentials, encryption key, and other deployment-owned values. Keep Java property escapes intact, especially in credentials and non-ASCII text. Record which settings remain disabled during validation. Apply the changes by restarting in the next step.

8. Start CARLOS and check the migrated clinic

Only after passed verification and approved settings, start the application using the normal configuration/restart command:

sudo carlos-ctl restart
sudo carlos-ctl check
sudo carlos-ctl db-validate
sudo carlos-ctl logs -n 200

Allow the application time to deploy, typically around two minutes. Investigate failed health probes and application errors before proceeding. A passing schema validation establishes that Flyway's migration history matches the package; it does not replace clinical data checks.

Read the new administrator credentials privately on the server:

sudo less /var/lib/carlos-emr/o19-import/admin-credentials.txt

Sign in through the new server's HTTPS address with that account and complete the required password change. Do not use the installer credentials for the removed carlosdoc account. Existing clinic logins retain their legacy password hashes, which upgrade on first login, but all imported users are required to reset their passwords. Expired accounts, missing roles, and invalid login names still need attention.

O19 permitted login names that CARLOS's login form refuses. Names containing punctuation such as ., _, @, or - import intact but need renaming through Administration > Security before those users can sign in.

Read the reports

Files below are under /var/lib/carlos-emr/o19-import/. Review them privately; detailed files can identify patients or staff. Share only appropriately redacted extracts.

File What it helps you verify
import-report.txt / import-report.json Final verdict, input and manifest identity, counts, content checks, archives, accepted limitations, and remaining operator work.
report.txt Chronological account of what each phase did.
content-transfer.json Source digest comparison with staging, or why that comparison was unavailable.
documents-details.txt Document, image, HRM, or path problems requiring investigation.
roles-details.txt Activated assignments, dormant admin assignments, fallback membership, expired or unusable accounts, and other access issues.
privilege-diff.txt Grants changed by CARLOS's seed data and custom-role backfill, including access gained.
verify-details.txt / content-details.txt Detailed spot checks and identifiers for content mismatches.
verify-problems.txt The full verification failure list when the main report's displayed list is truncated.

Some diagnostic files are created only when applicable. Read what was not checked as carefully as the passed checks. A report can pass with explicitly accepted limitations. Certain tables deliberately rewritten after copying are labelled NOT CHECKED for the value comparison and still receive row-count checks.

Review access with a clinic administrator. CARLOS's seeded permissions win on the same role/object; some clinic grants append, and custom roles may receive permissions from a matching stock role. Some users therefore gain access, while other custom roles need manual grants. Dormant NULL admin assignments remain dormant. Verify permissions for the real roles used by the clinic rather than assuming the O19 permission matrix is unchanged.

Check representative clinic work

Use authorized reviewers and known source records, keeping identifiers in a protected reconciliation record. Include older and newer data, accented text, complex charts, and records affected by assessment findings.

  1. People and schedules: find patients by their usual identifiers; compare demographics, providers, appointments, and appointment history.
  2. Clinical chart: compare encounter text, signing provider, dates, diagnoses, measurements, preventions, and follow-up work. Review prevention codes the importer could not map.
  3. Medication history: open allergies and prescriptions, confirm readable historical entries, and check DrugRef lookups if prescribing is in scope.
  4. Results and documents: open older and recent scanned files, laboratory results, and HRM reports from their patient charts. Confirm file contents belong to the expected patient, not just that a filename exists.
  5. Forms: open representative saved eForms, confirm image assets load, and check PDF generation and printing. Review disabled forms and any Rich Text Letter modernization advisory. The stock Rich Text Letter has specific importer fixups; clinic-modified templates still need review.
  6. Billing and local configuration: compare billing history, province-specific workflows, fees, templates, and lookup customizations called out in the report.
  7. Team work and access: review messages, ticklers, referrals, Inbox work, provider links, and access using representative clinic roles.
  8. Integrations: validate connections under the agreed test/cutover arrangement. Check that background jobs and inbound feeds have the intended single destination before releasing live traffic.

Perform write/save tests on the rehearsal copy. On the final server, keep review activity coordinated so genuine new clinic work begins only at the agreed cutover. The project's automated migrated-chart UI smoke test changes login rows during testing and is intended for a rehearsal host; see the release validation instructions.

9. Back up, complete cutover, and clean up

After settings and checks are complete, take and verify a post-import backup:

sudo carlos-ctl backup full
sudo carlos-ctl backup verify
sudo carlos-ctl backup status
sudo carlos-ctl backup snapshots

Record the new snapshot IDs alongside the pre-import recovery points. Confirm the clinic's review is complete, record the cutover time, switch the clinic's access and integrations as planned, and keep O19 closed to new writes. This importer does not merge work entered separately into both systems. If a fallback becomes necessary after CARLOS has received clinical work, preserve that work and agree how it will be reconciled before reopening O19.

Retain archived material

The importer creates a private CSV handoff under /var/lib/carlos-emr/o19-import/o19-archive-export/. Retain it with its README.txt, which explains representation of NULL and binary values, and retain the migration reports with the clinic's protected records.

The nightly database backup does not dump the separate o19_archive database. The import_archived_ objects inside the CARLOS database are backed up, and the archive-export directory is covered by the files backup. Reference and merge-table source rows may have their only database archive in o19_archive; retain and verify the CSV handoff, or arrange a separate backup of that schema if a queryable database archive is required.

The pre-import/files backup excludes the generated administrator credential note, derived property fragments, extracted bundle directories, and source oscar.properties in the workspace. Keep the original source backups securely available through acceptance and recovery; a target snapshot is not a substitute for retaining the import inputs. Once approved settings are applied to the deployed carlos.properties, that configuration is covered by the normal files backup.

When verification and review have passed and the post-import backup has succeeded, clean up the temporary import workspace:

sudo carlos-ctl import-o19 --cleanup

Cleanup drops o19_import and the temporary restore account, removes extracted bundle copies, and renames the run's ledgers, reports, detailed files, properties fragments, and archive-export directory with a shared .completed-<timestamp> suffix. It keeps o19_archive, the import_archived_ tables/columns, and admin-credentials.txt. For example, the CSV export is then found under:

/var/lib/carlos-emr/o19-import/o19-archive-export.completed-<timestamp>/

Keep the retained reports/export in protected storage and apply the clinic's retention policy to the source files, credentials, and redundant working copies. Cleanup does not remove the original three backups in /srv/migration, make the populated target eligible for another import, or reverse the migration. Confirm the next normal backup succeeds after cleanup, or run another backup full to capture the final retained layout.

Resume or roll back a migration

Continue a failed or interrupted real import

Keep CARLOS stopped. Read the last error and report.txt, correct the stated cause, and repeat the same real-import command with --resume appended. For the three-backup example:

sudo carlos-ctl import-o19 \
  --dump /srv/migration/o19.sql.gz \
  --documents /srv/migration/o19-documents.tar.gz \
  --properties /srv/migration/oscar.properties \
  --admin-user MigrationAdmin \
  --accept no-content-digests \
  --resume

Use your original digest option, administrator name, and any role-template options. Recorded real-run acknowledgements survive resume; repeating them makes the saved command easier to audit. Keep the original dump, tar, and properties unchanged. If using a bundle, keep the bundle, checksum, and password file available because resume reads it again.

Do not delete state.json, etl-progress.json, or the workspace to get past a refusal. They are the record of completed writes. Do not use a dry run or assessment over an import in progress. If the only previous activity was assessment/dry run, there is no real import to resume; run the normal import without --resume.

--restage deliberately replaces the staging database and clears its assessment. Use it only when replacing a staged source before data copying has begun, following the tool's message. Once copying starts, mixing in a different dump is refused and requires recovery to the pre-import state. A different documents tar after its restore has begun also requires that recovery; a failed reconciliation can instead be repaired in place as described below.

Return to the pre-import target

There is no one-command import-o19 --rollback. The documented recovery is to restore the pre-import CARLOS backup or a complete, consistent pre-import host snapshot tested during rehearsal.

  1. Stop CARLOS and preserve the failed run's reports and inputs. During a restic restore, stop the backup and verification timers and any active backup/verification services, as the installed recovery procedure directs.
  2. Select the recorded pre-import database and files snapshots. Do not blindly use latest, which may now refer to a partial or completed migration. Follow section Backups and restore in /usr/share/doc/carlos-emr/README.Debian, also available in the checked release's recovery reference, using this host's configured database name.
  3. Restore the database, document tree, configuration, and import workspace to the same pre-import state. A files restore over an existing directory does not remove files created later; the recovery must account for those additions. Because the bulk import disables binary logging, binary-log replay cannot reconstruct the import. Do not replay later changes when the intention is to return to the unused target.
  4. If the tool reports that state.json and the ETL ledger describe different runs after the restore, move the stale workspace aside as its message directs. The documented example is sudo mv /var/lib/carlos-emr/o19-import /var/lib/carlos-emr/o19-import.rolled-back, provided that destination is unused. Moving it is not itself a database rollback. Check for leftover staging/archive schemas and restore the full pre-import estate before starting again.
  5. Validate the restored schema, restore normal backup scheduling, and keep the target stopped until the next import is ready. Regenerate the derived properties fragment on the new run; it is excluded from backup. The new import will check again that the target is stock.

--cleanup can retire an unused staging run or a verified completed import, subject to archive-preservation checks. It refuses a partially copied import and may also refuse staging containing archive-only rows without verified preserved copies. It is not an abort-and-undo operation. destroy-data deletes clinic data, both import schemas, and the workspace; it is a decommission/reprovision operation, not the resume procedure.

Troubleshooting

Symptom Check and remedy
“Only on a stock initial deploy” The target contains non-seed logins, demo data, clinical data, or previous import objects. Use a fresh target or restore its tested pre-import state. Review pristine-details.txt when present. There is no production override.
CARLOS is running or starting Stop it with sudo carlos-ctl stop, confirm inactive, and retry or resume as appropriate. Keep it stopped until verification and settings review finish.
Province or manifest mismatch Check the host's configured province and installed application/CLI packages. Use a supported matching target; --province does not convert a schema. Keep package versions fixed through import and cleanup.
Dump contains USE, CREATE DATABASE, GTID, trigger/view DEFINER, or privileged statements Obtain a compatible single-database logical export. Use source preflight to identify views to exclude. Do not grant the staging account broader privileges to force the restore.
Missing dump completion trailer or decompression failure Treat the backup as incomplete until the source operator verifies or replaces it.
Missing or mismatched source digests Check the source snapshot time and digest format. Missing proof requires the explicit decision in step 3; differing values require investigation.
Documents reconciliation fails Read documents-details.txt. Missing/empty files, subdirectory or dot-leading document names, missing eForm images, and HRM filename collisions can block completion. Repair the correct files in place under /var/lib/carlos-emr/CarlosDocument/carlos/, then resume with the original tar. Do not substitute another patient's file with the same name.
Document restore was interrupted Resume with the same tar. Already moved files are checked; differing content is refused. Do not use --skip-documents to retire a restore already started.
An eForm image exists but its reference cannot be routed Review the separate advisory for subdirectories or query suffixes in the form HTML. Correct the form during controlled review and confirm it renders before releasing that workflow.
Values too long, non-numeric values, row-width errors, or unrepairable encoding The tool refuses potentially destructive conversion. Investigate with the maintainer and source operator, preserve the original content, and rehearse the approved correction. Do not truncate clinical text just to clear the check.
Sign-in fails after import Use the generated emergency administrator, complete password reset, and check expired accounts, alphanumeric login names, active roles, facility/program membership, and roles-details.txt.
A custom role has too much or too little access Read privilege-diff.txt and roles-details.txt, review stock-template choices, and adjust through Administration. A role-template mapping cannot be changed after its backfill decision is bound to a run.
Disk space or SQL statement timeout Resolve the named volume/query problem, then resume. --statement-timeout SECONDS bounds individual statements; 0 is unbounded. A timeout is a failure to investigate, not proof of safe completion.
Another import holds the workspace lock Identify the named process and let the intended run finish. Do not run two imports over the same workspace or delete its lock to bypass coordination.
Cleanup is refused Read the specific state or archive-parity failure. Preserve the ledgers and staged data; finish verification or use the recovery procedure.

For help, record the exact package versions, failed phase, redacted error, input checksums, and whether the target has received writes. Keep passwords, source properties, patient filenames, and private detail reports out of public issues.

If the backups arrived as one bundle

The separate-file route above needs no bundle. If you already have a compatible bundle, use it instead of --dump, --documents, and --properties.

A bundle must be .tar, .tar.gz, .tar.enc, or .tar.gz.enc, with exactly one SQL dump and one properties file at its root, at most one documents tar, and at most one content-digest JSON file. Members must be plain files without directory prefixes; unrelated files and duplicate roles are refused. A general server-backup tar is not necessarily an import bundle.

For an encrypted bundle, obtain its password and SHA-256 through a channel separate from the file. Save the password in a root-only file, then assess using:

sudo carlos-ctl o19-preflight \
  --bundle /srv/migration/o19-bundle.tar.gz.enc \
  --bundle-sha256 REPLACE_WITH_THE_SUPPLIED_SHA256 \
  --bundle-pass file:/srv/migration/passfile

Use the same three bundle options with import-o19 --dry-run, and then import-o19 --admin-user MigrationAdmin plus any approved acknowledgement flags. If no digest JSON is inside the bundle, supply --o19-digests separately or follow the missing-digest decision in step 3. A bundle checksum and database content digests prove different things; one does not replace the other.

The default decryption is AES-256-CBC with PBKDF2 and 200,000 iterations. For an older bundle, match its creator's settings with --bundle-cipher and repeated --bundle-openssl-opt arguments. Any supplied OpenSSL options replace the default derivation options; consult man carlos-ctl and the creator's recipe before changing them. Keep the original bundle and password file through resume and cleanup.

Related guides and source references

Installation · Backups and recovery · Administration commands · Properties reference · Data import and export · Upgrades and migration

Back to top

CARLOS documentation

All topics · Get help

Using CARLOS

Start here · Clinic workflows

Getting started and everyday reference
Office staff
Clinical staff and doctors
Clinic managers and administrators

Technical documentation

Technical overview · Reference

Running CARLOS

Install and configure
Maintain and troubleshoot

Developing CARLOS

Code, interfaces, and tests
Contribute and maintain releases

For everyone

Write and maintain the documentation

Clone this wiki locally