Disaster Recovery in 2019: Why Your "Backups" Won't Save You When the Kernel Panics
There are two types of system administrators: those who have lost data, and those who are about to. If you think a nightly tarball stored on the same physical disk as your production database constitutes a Disaster Recovery (DR) plan, you are a ticking time bomb. In the harsh reality of systems architecture, hardware hates you. RAID controllers fail silently. File systems corrupt. And yes, even in 2019, fat-finger errors like rm -rf /var/lib/mysql happen to the best of us.
I recently audited a setup for a mid-sized e-commerce platform in Oslo. They had "backups." But when we simulated a total facility outage, their Recovery Time Objective (RTO) drifted from "1 hour" to "3 days." Why? Because they were backing up data, not infrastructure. They had the SQL dumps but no automated way to provision a fresh environment to restore them to.
This guide isn't about buying expensive enterprise backup software. It's about using standard, battle-tested Linux tools—which you can run on high-performance infrastructure like CoolVDS—to ensure that when the lights go out, your service stays on.
The Legal Reality: GDPR, Datatilsynet, and Your Server
Since GDPR went into full enforcement last May, the stakes have changed. It's not just about losing money; it's about compliance. Article 32 explicitly requires the "ability to restore the availability and access to personal data in a timely manner."
For Norwegian businesses, relying on US-based cloud giants introduces a layer of anxiety regarding the Cloud Act. Keeping your DR site within Norway or the EEA isn't just a latency preference; it's a legal safeguard. This is why we insist on local hosting. When your failover node is sitting on a VPS Norway instance, you are dealing with Norwegian jurisdiction and the predictable oversight of Datatilsynet, not a subpoena from a foreign entity.
Step 1: The Database – Consistency is King
A raw file copy of /var/lib/mysql while the database is running is useless. You need a consistent snapshot. For MySQL or MariaDB (standard on most stacks in 2019), mysqldump is reliable, but it locks tables if you aren't careful. For high-traffic sites, you must use the single-transaction flag to avoid downtime.
Here is the correct way to dump a modern InnoDB database without locking your application:
#!/bin/bash
# /opt/scripts/db_backup.sh
BACKUP_DIR="/backup/mysql"
DATE=$(date +%Y-%m-%d_%H-%M)
DB_USER="backup_user"
DB_PASS="s3cur3p@ssw0rd"
# Ensure directory exists
mkdir -p $BACKUP_DIR
# The critical flags:
# --single-transaction ensures data consistency without locking tables for InnoDB
# --quick retrieves rows one by one instead of buffering the whole set
mysqldump -u$DB_USER -p$DB_PASS --all-databases \
--single-transaction \
--quick \
--triggers \
--routines \
--events | gzip > $BACKUP_DIR/db_backup_$DATE.sql.gz
# Prune backups older than 7 days
find $BACKUP_DIR -type f -name "*.sql.gz" -mtime +7 -delete
Pro Tip: Never store this script in your web root. And for the love of uptime, test your restore process. A backup that hasn't been restored is Schrödinger's Backup—it both exists and doesn't exist until you verify it.
Step 2: The Filesystem – Incremental Offsite Sync
Once you have your database dump, you need to get it—and your web files—off the server. Local backups die with the server. We use rsync because it's efficient, only transferring the delta (changes) rather than the whole file set. This is crucial if you are pushing gigabytes of media across the wire.
However, pure bandwidth isn't the only bottleneck. Disk I/O often chokes backup processes. This is where the underlying infrastructure matters. On spinning rust (HDD), a heavy rsync operation can cause iowait to spike, making your website sluggish. This is why CoolVDS deploys strictly on NVMe storage. The IOPS capacity of NVMe allows you to run heavy backup jobs in the background without your users noticing a millisecond of lag.
Here is a robust rsync command to push data to your DR node:
rsync -avz -e "ssh -p 2222" \
--bwlimit=5000 \
--delete \
--exclude 'cache/' \
--exclude 'logs/' \
/var/www/html/ \
user@dr-server.coolvds.net:/var/www/html_dr/
Understanding the Flags
| Flag | Function | Why use it? |
|---|---|---|
-a |
Archive mode | Preserves permissions, owners, and timestamps. Critical for web servers. |
-z |
Compress | Compresses data during transfer to save bandwidth. |
--delete |
Delete extraneous | Ensures the DR site matches production exactly (removes deleted files). |
--bwlimit |
Bandwidth Limit | Prevents the backup job from saturating your network uplink. |
Step 3: Infrastructure as Code (Even in 2019)
If your production server melts, you don't want to spend 4 hours installing Apache and PHP manually. You need a setup script. While tools like Puppet and Chef have been around, Ansible has become the de-facto standard for simplicity. It works over SSH, requires no agent, and documents your infrastructure.
Below is a snippet of an Ansible playbook that configures a fresh CoolVDS instance to be ready for code deployment in minutes. This effectively lowers your RTO.
---
- hosts: dr_servers
become: yes
tasks:
- name: Install Nginx and PHP-FPM
apt:
name: ["nginx", "php-fpm", "php-mysql", "unzip"]
state: present
update_cache: yes
- name: Configure Nginx Virtual Host
template:
src: templates/nginx.conf.j2
dest: /etc/nginx/sites-available/default
notify: Restart Nginx
- name: Ensure Firewall allows HTTP/HTTPS
ufw:
rule: allow
port: '{{ item }}'
proto: tcp
loop:
- '80'
- '443'
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted
The "Hot Standby" Approach
For mission-critical applications where downtime costs thousands of kroner per minute, a nightly backup isn't enough. You need a Hot Standby. This involves setting up MySQL Master-Slave replication. The Master (production) writes updates, and the Slave (DR on CoolVDS) replicates them in near real-time.
Warning: Replication is not a backup. If you run DROP TABLE on Master, it replicates to Slave instantly. You still need the point-in-time snapshots we discussed in Step 1.
To configure the slave, you need to edit my.cnf (or mysqld.cnf on Ubuntu 18.04):
[mysqld]
server-id = 2
relay-log = /var/log/mysql/mysql-relay-bin.log
log_bin = /var/log/mysql/mysql-bin.log
read_only = 1 # Crucial: Prevent accidental writes to the DR DB
Why Hardware Isolation Matters
We often see developers using container-based VPS solutions (like OpenVZ) for their DR sites. This is risky. In container virtualization, you share the kernel with every other tenant on the host node. If a neighbor triggers a kernel panic, your DR site goes down with them.
This is why true KVM virtualization is non-negotiable for serious recovery planning. KVM provides full hardware virtualization. Your OS kernel is your own. If the host is under heavy load, your reserved resources are protected. CoolVDS uses KVM exclusively because we believe predictable performance is a feature, not a luxury.
Final Thoughts: Don't Wait for the Fire
A Disaster Recovery plan is like insurance—you hate paying for it until you need it. By leveraging simple, powerful tools like rsync and Ansible, and hosting your failover infrastructure on reliable, high-speed NVMe VPS Norway servers, you mitigate the risks inherent in our industry.
The stability of the Norwegian power grid and the legal protections of the EEA make Oslo an ideal location for your primary or secondary data residence. Don't let a hardware failure become a business failure.
Ready to harden your infrastructure? Deploy a KVM-based, NVMe-powered instance on CoolVDS today and sleep better tonight.