Back up and restore MariaDB with mariadb-dump
Create a consistent logical backup with routines, events, triggers, metadata, compression, encryption, checksums, retention, and an isolated restore test.
Produce a portable MariaDB backup whose completeness and recovery time are proven rather than assumed.
- MariaDB 10.11 LTS, 11.4 LTS
- Recovery access and maintenance window Keep console access and schedule write-affecting work so an interrupted package, grant, backup, or replication change can be recovered.
- Verified backup Create a fresh backup and prove that its format, encryption key, and restore procedure are available before changing production data.
- Capacity and compatibility Check database version, storage headroom, character sets, application driver compatibility, and expected downtime.
df -h; df -i; free -m
OneLiners never runs these steps or stores secrets. Review placeholders, versions, current state, and change-control requirements before using a command.
Full guide
What you will build
- A production-ready MariaDB implementation of “Back up and restore MariaDB with mariadb-dump” with explicit identities, configuration ownership, observable checkpoints and a tested reversal path.
- A before-state, native validation sequence and concrete evidence set covering the database service, client behavior, data or administrative surface affected by this procedure.
- A least-privilege operational runbook that keeps secrets out of commands and verifies both the required success path and an expected denial or failure boundary.
- Produce a portable MariaDB backup whose completeness and recovery time are proven rather than assumed. The result is demonstrated through the guide's native verification commands and representative application or restore evidence.
- Unrelated databases, accounts, listeners and services remain unchanged; operators can identify the exact revision, artifact and rollback action for this change.
Architecture
How the parts fit together
A minimally privileged backup identity produces a transaction-consistent logical stream. The stream is compressed, integrity-checked, encrypted to approved recipients and moved to storage outside the database failure domain. Restoration always targets an isolated database or host first, where schema, row counts, checksums and application queries are verified. Retention and deletion begin only after restore evidence is recorded.
- Capture effective configuration, versions, listeners, identities, grants, workload health and a recoverable before-state.
- Prepare the logical backup candidate using only official MariaDB interfaces, protected secret delivery and the narrowest necessary scope.
- Apply one controlled layer at a time, run the immediate checkpoint and inspect native logs/status before proceeding.
- Perform end-to-end success and expected-failure tests; retain rollback evidence and schedule recurring verification.
Assumptions
- The installed MariaDB family and version are supported by the official sources linked below, and package/configuration provenance is known.
- A maintenance or canary window, current recoverable backup and console-level recovery path exist before state-changing database work begins.
- Operator, application, backup, replication and web-administration identities are separate; secrets are supplied by protected option files, environment injection with appropriate controls, or a secret manager.
- Representative schema size, workload, storage capacity, network policy and recovery objectives are documented for the target environment.
Key concepts
- user@host identity
- MySQL-family authorization matches both an account name and its permitted client origin, not the name alone.
- effective configuration
- The final runtime values after packaged defaults and ordered configuration fragments have been combined.
- consistent state
- Data and metadata captured at one valid transactional or recovery point rather than a mixture of moments.
- recovery objective
- The acceptable data-loss window and restoration time that drive backup, replication and validation design.
- positive and negative verification
- Proving an intended operation succeeds and an operation outside the granted/security boundary fails.
Before you copy
Values used in this guide
{{ageRecipientsFile}}Operator-reviewed value used by this tutorial for ageRecipientsFile; derive it from the target environment and never from untrusted request data.
Example: /etc/backup/age-recipients.txt{{backupName}}Operator-reviewed value used by this tutorial for backupName; derive it from the target environment and never from untrusted request data.
Example: mariadb-2026-07-25T020000Z.sql.zst.age{{backupOsGroup}}Operator-reviewed value used by this tutorial for backupOsGroup; derive it from the target environment and never from untrusted request data.
Example: dbbackup{{backupOsUser}}Operator-reviewed value used by this tutorial for backupOsUser; derive it from the target environment and never from untrusted request data.
Example: dbbackup{{backupTarget}}Operator-reviewed value used by this tutorial for backupTarget; derive it from the target environment and never from untrusted request data.
Example: s3-compatible-offhost:database-backups{{backupTargetLocalMount}}Operator-reviewed value used by this tutorial for backupTargetLocalMount; derive it from the target environment and never from untrusted request data.
Example: example-backuptargetlocalmount{{backupUser}}Operator-reviewed value used by this tutorial for backupUser; derive it from the target environment and never from untrusted request data.
Example: backup_agent{{databases}}Operator-reviewed value used by this tutorial for databases; derive it from the target environment and never from untrusted request data.
Example: example-databases{{protectedSecret}}Operator-reviewed value used by this tutorial for protectedSecret; derive it from the target environment and never from untrusted request data.
Example: example-protectedsecret{{restoreDir}}Operator-reviewed value used by this tutorial for restoreDir; derive it from the target environment and never from untrusted request data.
Example: /srv/restore/mariadb-2026-07-25{{restoreHost}}Operator-reviewed value used by this tutorial for restoreHost; derive it from the target environment and never from untrusted request data.
Example: db-restore.example.com{{restoreReport}}Operator-reviewed value used by this tutorial for restoreReport; derive it from the target environment and never from untrusted request data.
Example: example-restorereport{{restoreUser}}Operator-reviewed value used by this tutorial for restoreUser; derive it from the target environment and never from untrusted request data.
Example: restore_operatorSecurity and production boundaries
- Never place database passwords, encryption keys, recovery codes or private certificates directly in reusable shell history or repository files.
- Do not use `%`, global grants, disabled TLS verification, public administrative interfaces or world-readable dumps as troubleshooting shortcuts.
- Treat backups, slow logs and phpMyAdmin sessions as sensitive data; encrypt, restrict, rotate and monitor them according to the same or stronger policy as production.
Stop before continuing if
- Stop if the server version/config family is ambiguous, the backup cannot be restored, secrets would be exposed, or a proposed command affects databases/accounts beyond the declared scope.
- Do not continue when native validation, representative workload, expected-denial test, TLS identity, replication continuity or storage capacity evidence is incomplete for this procedure.
- Immediately isolate or revert a change that broadens a listener/grant, breaks application health, introduces replication error, loses recoverability or produces unbounded sensitive logs.
instruction
Define recovery objectives and backup scope
Document databases, routines, events, triggers, users, expected size, RPO, RTO, retention, encryption key owner, and restore target.
Why this step matters
Define recovery objectives and backup scope is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Document databases, routines, events, triggers, users, expected size, RPO, RTO, retention, encryption key owner, and restore target. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Define recovery objectives and backup scope”. The scope must remain limited to the selected application and supported host.
Syntax explained
mariadb- Invokes the principal tool or configuration operation for “Define recovery objectives and backup scope”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
sudo mariadb -NBe "SHOW DATABASES"; sudo mariadb -NBe "SELECT table_schema, ROUND(SUM(data_length+index_length)/1024/1024) MiB FROM information_schema.tables GROUP BY table_schema"Scope, size, RPO, RTO, and retention are recorded.
Checkpoint: Checkpoint: Define recovery objectives and backup scope
Continue whenScope, size, RPO, RTO, and retention are recorded. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when mariadb reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Define recovery objectives and backup scope” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v mariadb 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
command
Create a dedicated backup account
Grant only the privileges required by the selected dump options and restrict the account to local socket or backup host.
Why this step matters
Create a dedicated backup account is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Grant only the privileges required by the selected dump options and restrict the account to local socket or backup host. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Create a dedicated backup account”. The scope must remain limited to the selected application and supported host.
Syntax explained
mariadb- Invokes the principal tool or configuration operation for “Create a dedicated backup account”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
Values stay on this page and are never sent or saved.
sudo mariadb --protocol=socket -e "CREATE USER IF NOT EXISTS '{{backupUser}}'@'localhost' IDENTIFIED BY '{{protectedSecret}}'; GRANT SELECT, SHOW VIEW, TRIGGER, EVENT, LOCK TABLES, RELOAD, PROCESS ON *.* TO '{{backupUser}}'@'localhost';"A dedicated local backup account exists.
Checkpoint: Checkpoint: Create a dedicated backup account
Continue whenA dedicated local backup account exists. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when mariadb reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Create a dedicated backup account” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v mariadb 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
config
Store credentials in a protected option file
Use a 0600 client option file readable by the backup identity instead of command-line passwords.
Why this step matters
Store credentials in a protected option file is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Use a 0600 client option file readable by the backup identity instead of command-line passwords. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Store credentials in a protected option file”. The scope must remain limited to the selected application and supported host.
Syntax explained
install- Invokes the principal tool or configuration operation for “Store credentials in a protected option file”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
/etc/mysql/{{backupUser}}.cnf- Is the persistent configuration boundary changed by this step. Keep an attributable backup and validate the consumer before reload.
/etc/mysql/{{backupUser}}.cnfValues stay on this page and are never sent or saved.
sudo install -o {{backupOsUser}} -g {{backupOsGroup}} -m 0600 /dev/null /etc/mysql/{{backupUser}}.cnf; sudoedit /etc/mysql/{{backupUser}}.cnfThe option file contains the client user, socket, and secret with mode 0600.
Checkpoint: Checkpoint: Store credentials in a protected option file
Continue whenThe option file contains the client user, socket, and secret with mode 0600. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when install reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Store credentials in a protected option file” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v install 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
command
Create a consistent complete logical dump
Use single-transaction for transactional tables, include routines, events, triggers, and metadata, and fail the pipeline if mariadb-dump fails.
Why this step matters
Create a consistent complete logical dump is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Use single-transaction for transactional tables, include routines, events, triggers, and metadata, and fail the pipeline if mariadb-dump fails. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Create a consistent complete logical dump”. The scope must remain limited to the selected application and supported host.
Syntax explained
set- Invokes the principal tool or configuration operation for “Create a consistent complete logical dump”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
|- Passes standard output to the next read-only inspection stage; review each stage separately if the combined result is surprising.
Values stay on this page and are never sent or saved.
set -o pipefail; umask 077; mariadb-dump --defaults-extra-file=/etc/mysql/{{backupUser}}.cnf --single-transaction --quick --routines --events --triggers --hex-blob --databases {{databases}} | gzip -1 > /var/backups/mariadb/{{backupName}}.sql.gzA non-empty compressed SQL backup is created.
Checkpoint: Checkpoint: Create a consistent complete logical dump
Continue whenA non-empty compressed SQL backup is created. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when set reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Create a consistent complete logical dump” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v set 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
command
Encrypt and checksum the backup
Encrypt with the approved key-management tool, write a SHA-256 checksum, and securely remove plaintext only after verification.
Why this step matters
Encrypt and checksum the backup is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Encrypt with the approved key-management tool, write a SHA-256 checksum, and securely remove plaintext only after verification. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Encrypt and checksum the backup”. The scope must remain limited to the selected application and supported host.
Syntax explained
age- Invokes the principal tool or configuration operation for “Encrypt and checksum the backup”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
Values stay on this page and are never sent or saved.
age -R {{ageRecipientsFile}} -o /var/backups/mariadb/{{backupName}}.sql.gz.age /var/backups/mariadb/{{backupName}}.sql.gz; sha256sum /var/backups/mariadb/{{backupName}}.sql.gz.age > /var/backups/mariadb/{{backupName}}.sha256; shred -u /var/backups/mariadb/{{backupName}}.sql.gzEncrypted backup and checksum files exist; plaintext is removed.
Checkpoint: Checkpoint: Encrypt and checksum the backup
Continue whenEncrypted backup and checksum files exist; plaintext is removed. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when age reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Encrypt and checksum the backup” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v age 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
command
Copy to independent storage and apply retention
Transfer the encrypted artifact and checksum to immutable or independently administered storage, then enforce retention there.
Why this step matters
Copy to independent storage and apply retention is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Transfer the encrypted artifact and checksum to immutable or independently administered storage, then enforce retention there. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Copy to independent storage and apply retention”. The scope must remain limited to the selected application and supported host.
Syntax explained
rsync- Invokes the principal tool or configuration operation for “Copy to independent storage and apply retention”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
Values stay on this page and are never sent or saved.
rsync --archive --protect-args /var/backups/mariadb/{{backupName}}.{sql.gz.age,sha256} {{backupTarget}}/The remote target contains matching encrypted artifact and checksum.
Checkpoint: Checkpoint: Copy to independent storage and apply retention
Continue whenThe remote target contains matching encrypted artifact and checksum. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when rsync reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Copy to independent storage and apply retention” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v rsync 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
command
Restore into an isolated validation instance
Verify checksum, decrypt as a stream, restore to a disposable compatible MariaDB instance, and capture duration and errors.
Why this step matters
Restore into an isolated validation instance is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Verify checksum, decrypt as a stream, restore to a disposable compatible MariaDB instance, and capture duration and errors. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Restore into an isolated validation instance”. The scope must remain limited to the selected application and supported host.
Syntax explained
cd- Invokes the principal tool or configuration operation for “Restore into an isolated validation instance”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
&&- Runs the following operation only when the previous command succeeds, preventing a reload or state transition after a failed validation.
|- Passes standard output to the next read-only inspection stage; review each stage separately if the combined result is surprising.
Values stay on this page and are never sent or saved.
cd {{restoreDir}} && sha256sum -c {{backupName}}.sha256; set -o pipefail; age -d {{backupName}}.sql.gz.age | gzip -dc | mariadb --host={{restoreHost}} --user={{restoreUser}} --passwordRestore completes with exit code zero on the isolated target.
Checkpoint: Checkpoint: Restore into an isolated validation instance
Continue whenRestore completes with exit code zero on the isolated target. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when cd reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Restore into an isolated validation instance” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v cd 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
verification
Validate schema, rows, routines, and application queries
Compare table counts and selected invariants, list routines/events/triggers, and run a read-only application smoke suite.
Why this step matters
Validate schema, rows, routines, and application queries is a separate checkpoint because it establishes one auditable part of produce a portable mariadb backup whose completeness and recovery time are proven rather than assumed. Performing it independently keeps a failed prerequisite, syntax error, or compatibility mismatch from being hidden by later actions.
What to understand
Compare table counts and selected invariants, list routines/events/triggers, and run a read-only application smoke suite. Read the complete command or configuration before execution, replace the documented placeholders, and compare the target host with the supported environments listed at the beginning of this tutorial.
Capture the before-state and the exact output in the change record. If this step modifies a file or service, validate the candidate with its native checker before any reload; a successful process exit alone does not prove that the application uses the intended value.
Use a representative staging or canary host first. Repeat the stated checkpoint immediately, because proceeding with ambiguous evidence makes the later end-to-end verification and rollback materially harder.
System changes
- This step may affect the files, packages, identities, services, or runtime policy named in “Validate schema, rows, routines, and application queries”. The scope must remain limited to the selected application and supported host.
Syntax explained
mariadb- Invokes the principal tool or configuration operation for “Validate schema, rows, routines, and application queries”; confirm that it resolves to the expected packaged executable or file before using elevated privileges.
{{…}}- Marks an operator-supplied value. Replace every placeholder deliberately; do not paste untrusted text or leave braces in the production command.
Values stay on this page and are never sent or saved.
mariadb --host={{restoreHost}} --user={{restoreUser}} --password -e "SELECT table_schema,COUNT(*) FROM information_schema.tables GROUP BY table_schema; SELECT COUNT(*) FROM information_schema.routines; SELECT COUNT(*) FROM information_schema.events; SELECT COUNT(*) FROM information_schema.triggers;"Expected schemas, objects, invariants, and application reads pass.
Checkpoint: Checkpoint: Validate schema, rows, routines, and application queries
Continue whenExpected schemas, objects, invariants, and application reads pass. Treat this concrete evidence as the minimum success signal and also confirm that unrelated services and the previous healthy path remain unchanged.
Stop whenStop before the next step when mariadb reports an error, the output differs materially from the example, an unexpected package/service/path is affected, or the required before-state and rollback artifact are missing.
If this step fails
The command for “Validate schema, rows, routines, and application queries” fails, produces no useful evidence, or the expected service/configuration state is absent.
Likely causeA placeholder targets the wrong environment, the installed version uses another path or unit name, permissions are insufficient, or an earlier prerequisite was not satisfied.
command -v mariadb 2>/dev/null || truesystemctl --failed --no-pager 2>/dev/null || truejournalctl -p warning -n 50 --no-pager 2>/dev/null || true
ResolutionDo not improvise a privileged workaround. Re-read the environment and variable table, inspect the official source for the installed version, restore the candidate file if necessary, and repeat only this checkpoint.
Security notes
- Keep secrets out of shell history, process arguments, screenshots, logs, and tutorial placeholders. Elevate only the narrow command that requires it and preserve package signature and TLS verification.
Alternatives
- When the host layout or software version differs, use the vendor-supported equivalent in a disposable staging environment and document the mapping before touching production.
Stop conditions
- Stop if the action broadens network exposure, permissions, package sources, writable paths, or service privileges beyond the tutorial's declared architecture.
Finish line
Verification checklist
cd {{backupTargetLocalMount}} && sha256sum -c {{backupName}}.sha256The encrypted offsite artifact matches its checksum.cat {{restoreReport}}The latest isolated restore succeeded within the documented RTO and records the recovered backup timestamp.Recovery guidance
Common problems and safe checks
The native client reports access denied even though a similarly named account has grants.
Likely causeDatabase identities include a host component and authentication plugin; the connection matched another user@host row or transport.
mysql -e 'SELECT USER(), CURRENT_USER();'mysql -e "SELECT User,Host,plugin FROM mysql.user ORDER BY User,Host;"mysql -e 'SHOW GRANTS FOR CURRENT_USER;'
ResolutionIdentify the exact matched account and create or modify only the intended user@host identity; do not broaden it to '%' as a shortcut.
TLS is enabled but the client still connects with an unexpected identity or without hostname verification.
Likely causeThe client uses encryption-only mode, connects by an address absent from the SAN, trusts a broad system CA set, or another option file overrides policy.
mysql --print-defaultsopenssl s_client -starttls mysql -connect db.example.com:3306 -servername db.example.com </dev/nullmysql -e "SHOW STATUS LIKE 'Ssl_%';"
ResolutionUse the documented hostname, intended CA and VERIFY_IDENTITY-equivalent mode; remove conflicting client options and retest expected failure with a wrong hostname.
A change passes syntax checks but application errors, lag, latency or disk use increases.
Likely causeThe candidate is syntactically valid but workload, lock, cache, rotation, privilege or version assumptions are wrong.
mysqladmin pingmysql -e 'SHOW PROCESSLIST;'journalctl -u mariadb -u mysql -p warning --since '-10 min' --no-pager
ResolutionStop promotion, preserve evidence, revert the smallest changed configuration/account/routing layer and reproduce with a safe representative workload.
Reference
Frequently asked questions
Does a successful command mean the procedure is complete?
No. Database tools may return success before application compatibility, replica replay, restore integrity, TLS identity or expected denials are proven. Use every checkpoint and final verification.
Can an administrator use the application account for convenience?
No. Separate identities make least privilege, rotation, audit and incident containment possible; the application should not hold administrative capabilities.
Why test restoration or negative access separately?
A backup that cannot restore and a grant that was never tested for denial are assumptions, not controls. Isolation makes those tests safe and repeatable.
Recovery
Rollback
A backup job is additive; disable the new schedule and restore the prior job without deleting validated artifacts.
- Disable the new timer or scheduler entry and restore the prior backup configuration.
- Keep all newly created encrypted artifacts until retention and restore evidence are reviewed.
- Revoke the backup account only after no active job depends on it.
Evidence