Objectives and prerequisites
By the end of this course, you will be able to operate a service: monitor it, deploy it without breaking it, back up and restore, handle an incident, plan maintenance and document operations. The common thread is operating the Mdjad site and API on shared hosting.
Prerequisites: know Linux, web application deployment and container basics (courses F06 and F09). Examples use Bash, systemd, cron, Nginx/Apache, MariaDB and PromQL queries. Commands are presented for a test server.
Path: chapters 1 to 3 establish the operations role, inventory and monitoring; chapters 4 to 6 cover deployment, backups and incidents; chapters 7 to 9 cover maintenance, support and automation; chapter 10 assembles the operations plan.
Convention: an operation is reliable only if it is repeatable, measured and reversible. Every procedure states its purpose, prerequisites, check and rollback. An undocumented manual action is operational debt.
1. Operating, maintaining, evolving
Operating means running the service day to day: deploying, monitoring, handling incidents and requests. Maintaining means preventing drift: patches, dependencies, capacity, backups. Evolving means adding value without breaking what exists.
Operations : availability, deployments, incidents, requests
Maintenance: patches, dependencies, certificates, capacity
Evolution : new features, migrations, debt
Steering : SLOs, error budget, costs, reviews
These three activities compete for the same time. A team that only evolves accumulates debt; a team that only operates improves nothing. Steering makes this trade-off visible with numbers and priorities.
Roles must be clear: who owns the service, who answers alerts, who approves a deployment, who talks to users. On-call without a procedure is a source of stress and errors. A service without an owner has nobody to decide.
Service level is measured, not declared. A 99.5 % SLO during business hours does not cost the same as a permanent 99.99 % SLO. The resulting error budget either allows risky deployments or imposes caution.
Finally, distinguish incident, request and change. An incident restores a degraded service; a request provides information or access; a change modifies the system. Mixing the three in one queue makes priorities unreadable and lead times uncontrollable.
2. Inventory, documentation and access
You cannot operate what you do not know. The inventory lists servers, services, databases, domains, certificates, scheduled tasks and their owners. It is dated and versioned, like the rest of the code.
Service | Host | Depends on | Owner
site-mdjad | o2switch (shared)| MariaDB, SMTP | operations
api-catalogue | o2switch (shared)| MariaDB | product
cron-messenger | o2switch (shared)| site-mdjad | operations
backup | external storage | site-mdjad | operations
Operations documentation describes the procedures actually used: deploy, roll back, restore, renew a certificate, add an account. It lives near the code and is updated after every incident. Outdated documentation is more dangerous than none.
Access follows least privilege and is named. Shared accounts prevent knowing who did what and complicate departures. Secrets are stored in a vault or a protected file, never in a repository or a ticket.
Plan rotation and revocation: what happens when someone leaves the team or a key leaks? The answer must be a tested procedure, not improvisation. Emergency access is exceptional, logged and revoked after use.
Finally, the inventory must include external dependencies: SMTP, CDN, payment gateway, third-party APIs. Their unavailability is a service outage even if your code works. Note contacts and service commitments.
3. Monitoring: metrics, logs, traces
Monitoring answers three questions: is the service working, are users being served, and why does a problem occur? Metrics give trends, logs give details, traces give the path of a request. The three complement each other.
Golden signals: latency, traffic, errors, saturation
Metric : numeric value over time (requests/s, p95)
Log : dated, contextual event (error, access)
Trace : path of a request across services
Alert : rule that triggers human action
Watch the four golden signals: latency, traffic, errors and saturation. Average latency hides slow users; use percentiles. An error rate computed over too short a window is noisy; too long a window delays detection.
sum(rate(http_requests_total{status=~"5.."}[5m]))
/ sum(rate(http_requests_total[5m]))
Alerts must be actionable. An alert that fires with no possible action is noise and teaches people to ignore the next ones. Every alert has an owner, a justified threshold, a link to a runbook and a way to be tested.
Logs must be structured and correlated by a request identifier. Without correlation, finding the cause of an error becomes a manual hunt. Beware personal data: a log must not contain passwords, tokens or sensitive content.
Finally, measure the real experience: availability as users see it, load time, failure rate of critical journeys. An internal probe can be green while the service is unreachable from outside. Test from several points.
4. Deploying and rolling back
A deployment must be reproducible: same artefacts, same steps, same result. Dependencies are locked, migrations are versioned and environment variables are documented. An untracked manual deployment is not reproducible.
#!/usr/bin/env bash
set -euo pipefail
APP_DIR="/var/www/mdjad"
RELEASE="$(date -u +%Y%m%d%H%M%S)"
git -C "$APP_DIR" fetch --prune origin
git -C "$APP_DIR" checkout --detach "origin/main"
composer install --no-dev --optimize-autoloader --classmap-authoritative
php bin/console doctrine:migrations:migrate --no-interaction
php bin/console cache:clear --env=prod
sudo systemctl reload php-fpm
echo "Deployment $RELEASE complete"
Rollback must be prepared before deployment. Returning to the previous commit is easy; reversing a destructive migration is not. Split migrations into compatible steps: add, write, migrate, remove. The code must tolerate both schemas during the transition.
Deployment strategies vary: stop and restart, blue/green, canary. All require a health check and a stop criterion. Deploying without checking the service afterwards is betting on the absence of errors.
A successful deployment is not just a process that ends without error. Check critical journeys: home, login, order, payment, email. An automated smoke test catches obvious errors before users do.
Finally, log every deployment: version, author, time, content and result. During an incident, this trace correlates the change with the failure. Without it, root cause analysis starts with an investigation.
5. Backing up, restoring and planning
A backup is only valuable if it can be restored. Define the RPO, how much data you accept losing, and the RTO, the accepted downtime. These two numbers determine frequency, retention and cost.
#!/usr/bin/env bash
set -euo pipefail
STAMP="$(date -u +%Y%m%dT%H%M%SZ)"
DUMP="/var/backups/mdjad-$STAMP.sql.gz"
mysqldump --single-transaction --routines --triggers mdjad | gzip > "$DUMP"
test -s "$DUMP"
gzip -t "$DUMP"
sha256sum "$DUMP" > "$DUMP.sha256"
echo "Backup created: $DUMP"
Store backups outside the main server, on separate media with restricted access. A backup on the same disk as the database disappears with the server. Encrypt archives containing personal data and limit their retention.
Test restoration at regular intervals in an isolated environment. Restore, check the table count, a few critical records and application integrity. Record the actual duration: it determines whether the RTO is met.
Also plan for the loss of an external service: SMTP unavailable, slow storage, CDN outage. Document expected behaviour and user communication. A queue that absorbs emails during an outage avoids losing notifications.
Finally, keep logs and metrics long enough to analyse a past incident, without keeping them forever. Retention is a trade-off between cost, compliance and investigative capability.
6. Handling an incident
An incident is handled in phases: detection, triage, mitigation, resolution, communication and retrospective. Mitigation aims to restore service, not to fix the cause. Searching for the cause mid-outage prolongs downtime.
10:02 Alert error_rate_high (5xx > 2 % over 5 min)
10:04 Triage: site and API respond, errors on ordering
10:08 Mitigation: roll back to previous commit, health OK
10:15 Communication: status "ordering restored", monitoring
10:40 Resolution: cause identified in a migration
11:00 Post-mortem scheduled
Triage assesses impact: who is affected, which function, how severe. It appoints an incident lead and a communicator. One person coordinates, even if several technicians intervene. Collective improvisation slows resolution.
Communication is part of the service: status page, user message, support briefing. Incomplete and honest information is better than silence. Announce updates at regular intervals, even without progress.
The post-mortem is blameless and factual: timeline, impact, causes, what worked, what was missing, dated actions. Each action has an owner. A post-mortem without follow-up is a writing exercise that lets the incident return.
Finally, distinguish immediate cause from root causes. A migration broke ordering; why did no test catch it? Why did rollback take eight minutes? Root causes are often organisational.
7. Preventive maintenance
Preventive maintenance reduces the probability of incidents: security patches, dependency updates, certificate renewal, disk cleanup, capacity review. It must be scheduled, otherwise it never happens.
#!/usr/bin/env bash
set -euo pipefail
# Check certificate expiry and disk space.
for host in mdjad.net api.mdjad.net; do
expiry="$(echo | openssl s_client -servername "$host" -connect "$host:443" 2>/dev/null \
| openssl x509 -noout -enddate | cut -d= -f2)"
echo "$host expires on $expiry"
done
df -h / /var | awk 'NR == 1 || $5+0 >= 80 { print }'
Dependencies are updated in small batches, with release notes read and tests run. A major update is prepared: compatibility, migration, rollback. Updating everything at once makes attributing a regression impossible.
Certificates and domain names have deadlines. Automate renewal and monitor expiry. An expired certificate makes the site unreachable, and internal alerts may not see it.
Capacity is monitored: disk, memory, database connections, queue size. Predictable linear growth is handled before saturation. A full disk is an avoidable incident, often detected too late.
Finally, scheduled tasks are part of maintenance: queue consumption, GDPR purge, sitemap, backup. Monitor their last run. A silent cron that no longer runs is an invisible outage.
8. Support, requests and knowledge
Support receives heterogeneous requests: access, bug, question, evolution. A structured form and an explicit priority level avoid unmanageable queues. Priority depends on impact and urgency, not on the requester’s voice.
P1: service unavailable to everyone → immediate response
P2: critical function degraded → response within 1 h
P3: limited nuisance with workaround → response within 1 day
P4: information or evolution request → response within 5 days
Every ticket must have an identifier, requester, description, priority, owner and status. Duplicates are grouped; out-of-scope requests are politely refused. Support without scope becomes a channel for every frustration.
The knowledge base captures recurring answers: procedures, known errors, links to runbooks. It is updated from real tickets, not a theoretical plan. A documented answer reduces handling time and variation between technicians.
Support is also a product information source. Recurring tickets reveal interface defects, missing documents or training needs. Analyse trends at regular intervals.
Finally, protect data: a ticket must not contain passwords, tokens or unnecessary sensitive data. Attachments are checked. Ticket access is restricted and logged.
9. Automating and documenting operations
Automation reduces errors and time spent. It starts with repetitive and risky tasks: backup, renewal, purge, deployment. A script must be idempotent: running it twice breaks nothing.
#!/usr/bin/env bash
set -euo pipefail
# Purge expired consents, idempotent and traceable.
php /var/www/mdjad/bin/console app:gdpr:data-retention --env=prod
php /var/www/mdjad/bin/console messenger:stop-workers --env=prod || true
logger -t mdjad-maintenance "GDPR purge completed at $(date -u +%FT%TZ)"
Every automation has a check: exit code, log, metric, alert on failure. A silently failing cron is worse than a manual task because nobody sees it. Send output somewhere monitored.
Runbooks describe procedures step by step, with exact commands, checks and rollback. They are tested during drills and updated after every incident. An untested runbook often contains an outdated command.
Automate gradually: first a manually verified script, then a scheduled run, then an alert. Jumping straight to full automation of a poorly understood process locks in the errors.
Finally, version scripts and configurations like application code. A cron or Nginx change must be reviewed and traceable. Manual changes on the server create drift between the documented and the real environment.
10. Summary: Mdjad’s operations plan
The plan gathers inventory, SLOs, monitoring, procedures, backups, incidents, maintenance and support. It fits in a few pages and points to detailed runbooks. It is reviewed at regular intervals and after every major incident.
service: site-mdjad
owners: [operations]
slo: { availability: 99.5, latency_p95_ms: 800 }
backup: { rpo_minutes: 15, rto_hours: 4, restore_drill: quarterly }
maintenance: { patch_window: monthly, certificate_check: daily }
support: { p1_response: immediate, p3_response: 1_day }
on_call: { rotation: weekly, escalation: 15_minutes }
For Mdjad, operations rely on shared hosting, cPanel crons, a MariaDB database, external backups and simple but real monitoring. Hosting constraints are accepted: no system reboot, no heavy agents. Checks go through HTTP, logs and scheduled tasks.
The main risks are unrestored backups, silent crons, forgotten certificates and dependence on one person. Each has a measure, an owner and a planned action. The plan does not remove risks; it makes them visible and reviewable.
Coherence comes from the chain: every service has an owner, every alert a runbook, every procedure a check, every incident a post-mortem. When one piece changes, you know what to update. This chain makes operations sustainable.
Finally, operations is a continuous improvement discipline. Metrics, incidents and tickets feed priorities. A team that measures can arbitrate; a team that does not measure suffers.
Exercise 1 — Classify a request
A customer reports that the login page returns a 500 error for all users. Incident, request or change? Which priority?
Solution
It is an incident: the service is degraded for everyone. Priority P1, immediate response, mitigation first. Fixing the cause comes after recovery. User communication and a post-mortem are required.
Exercise 2 — Actionable alert
An alert “CPU > 80 %” fires every night. How do you improve it?
Solution
Tie the alert to an impact: latency, errors or real saturation. If the nightly peak is a scheduled backup, the alert is noise. Otherwise, add a duration threshold, a runbook and an owner. An alert must lead to an action.
Exercise 3 — Deployment and rollback
A migration removes a column used by the previous version. Why is this risky and how should you proceed?
Solution
Rollback fails because the previous version can no longer find the column. Proceed in steps: add the new column, write to both, migrate, verify, then remove the old one after a compatibility period. The code must tolerate both schemas.
Exercise 4 — Backup and RTO
A daily 20 GB backup takes 3 hours to restore, but the RTO is 4 hours. What are the risks and options?
Solution
The RTO is met narrowly, with no margin for verification and contingencies. Options: more frequent backups, incremental restore, faster storage, or revise the RTO with the business. Measure the actual restore, not the theory.
Exercise 5 — Incident and communication
During an incident, support receives ten identical messages. What do you do?
Solution
Group the messages into one incident, publish a common status and brief support. Reply to requesters with the status link and the next update. Avoid divergent individual replies.
Exercise 6 — Safe automation
A purge script must be rerunnable without harm. What precautions should you take?
Solution
Make it idempotent: explicit conditions, transactions, no cumulative effects. Add set -euo pipefail, a log, an exit code, a lock against concurrent runs and an alert on failure. Test on a copy before production.
Final project — Operations plan
Produce an operations plan for the Mdjad site and API: inventory, SLOs, monitoring, deployment, backups, incidents, maintenance, support and automation. Attach three runbooks: deploy, restore, handle an outage.
Criteria: inventory with owners; measurable SLOs; actionable alerts; reproducible deployment and rollback; restored and tested backup; incident procedure with communication; planned maintenance; prioritised support; idempotent scripts; no sensitive data in logs.
Common mistakes and diagnosis method
Common mistakes: never-restored backup; silent cron; alert without action; untracked manual deployment; destructive migration; forgotten certificate; full disk; incident without a lead; post-mortem without action; support without priority.
Method: for each service, check owner, SLO, monitoring, backup and runbook. For each alert, ask which action is expected. For each incident, timeline, impact, cause and dated action. For each procedure, test it in an isolated environment.
Self-assessment
You must be able to distinguish operations, maintenance and evolution, define an SLO and an RTO, monitor golden signals, deploy and roll back, restore a backup and run a post-mortem.
Self-assessment: I can explain why an untested backup does not count; I can describe rollback of a migration; I can classify an incident and a request; I can write an actionable alert. To go further, study SRE, ITIL and crisis management.
References
- Google SRE Book, accessed 23 October 2026.
- Google SRE Workbook, accessed 23 October 2026.
- ITIL 4, accessed 23 October 2026.
- PostgreSQL — Continuous Archiving, accessed 23 October 2026.
- MariaDB Backup, accessed 23 October 2026.