Ransomware attacks have become one of the most dangerous online threats for individuals and businesses today. These cyberattacks encrypt your data and demand payment to restore access, often leading to financial loss and downtime. Understanding how to protect your devices and what steps to take can make a huge difference. In this article, we’ll go through effective strategies to prevent ransomware attacks, maintain online safety, and strengthen your cybersecurity defenses.
Effective Ways to Prevent Ransomware Attacks
Ransomware spreads through phishing emails, malicious downloads, and software vulnerabilities. To prevent an attack, the first step is to always keep your software and operating system updated. Updates often include patches for security flaws that hackers exploit to install ransomware. Never ignore update notifications; instead, schedule them regularly to ensure your system is protected against the latest threats.
Another key prevention technique is to back up your data frequently. Store backups offline or on secure cloud services that offer strong encryption. This ensures that even if ransomware infects your device, you’ll be able to restore your files without paying the attackers. Automate your backups where possible to avoid forgetting critical data.
User awareness is the strongest defense against ransomware. Attackers rely on human error—like clicking suspicious links or downloading unknown attachments—to gain access. Educate yourself and your team to recognize phishing emails, double-check sender addresses, and distrust unsolicited attachments. Cybersecurity training can significantly reduce the risk of a successful attack.
Best Cybersecurity Tips to Stay Safe Online
Strong, unique passwords are the foundation of online safety. Use a password manager to create and store complex passwords for every account. Enable multi-factor authentication (MFA) wherever possible to add an additional layer of security that keeps hackers from accessing your data even if they steal your password.
Avoid public Wi-Fi whenever handling sensitive information. Unsecured networks can allow cybercriminals to intercept your data. If you must use public Wi-Fi, connect through a trusted Virtual Private Network (VPN) to encrypt your traffic. A VPN ensures that your data stays private, even on untrusted networks.
Keep your devices protected by using reliable antivirus and anti-malware tools. Regularly run scans and monitor for any signs of unusual activity. Many modern operating systems include built-in security features, but investing in a premium cybersecurity suite provides additional real-time protection against ransomware, keyloggers, and other threats.
Protect Your Devices from Hackers and Malware
One simple but powerful method to protect your devices is to disable macro scripts in Microsoft Office and other applications. Ransomware often hides in macro-enabled files sent through email attachments. Blocking these macros prevents automated scripts from running malicious code on your system.
Regularly review your network permissions. Only allow trusted applications, users, and devices to connect. Setting up a firewall and intrusion detection system helps monitor and filter incoming traffic, quickly identifying suspicious behavior. Network segmentation also ensures that if one part of your system is breached, the rest remains safe.
If you use smart devices or IoT gadgets, always change default usernames and passwords. Smart devices are common entry points for hackers when left unsecured. Keep their firmware updated and restrict remote access features when not needed. The fewer points of vulnerability, the lower your chance of being attacked.
Q&A: Common Questions About Ransomware
What should I do if I’m attacked by ransomware? Do not pay the ransom. Instead, disconnect from all networks, report the incident to cybersecurity authorities, and contact a professional recovery service. Then, restore your data from secure backups.
Can antivirus software stop ransomware? Yes, many modern antivirus programs can detect and block ransomware before it encrypts your files. However, no solution is 100% foolproof, so combining antivirus protection with good habits is essential.
Is ransomware prevention expensive? Not necessarily. Many effective security measures, such as regular updates, backups, and cybersecurity training, cost little or nothing but provide strong protection against ransomware attacks.
Ransomware prevention starts with awareness, preparation, and proactive protection. By keeping your systems updated, training yourself and your team, and using strong cybersecurity tools, you can minimize risks and safeguard your digital life. Staying vigilant and ready is the best way to stay safe from evolving cyber threats and keep your data secure online.
Hardware failures, botched package upgrades, accidental rm commands, and ransomware can wipe out a production host in seconds. Whether you run Ubuntu 24.04 LTS or Ubuntu 26.04 LTS, a tested Ubuntu backup plan lets you restore configurations, files, and databases cleanly instead of rebuilding from memory.
This guide covers the 3-2-1-1-0 rule, what to include and exclude, practical commands for rsync, tar, BorgBackup, and Restic, how Timeshift and Déjà Dup fit in, consistent database dumps, systemd timers, ransomware-proof offsite storage, and restore testing.
Key Facts: Ubuntu Server Backup at a Glance
LTS versions covered: Ubuntu 24.04 LTS (Noble Numbat) and Ubuntu 26.04 LTS (Resolute Raccoon, released April 2026 and supported until April 2031).
Primary tools: BorgBackup (1.2.8 in 24.04 / 1.4.4 in 26.04) or Restic (0.16.4 in 24.04 / 0.18.1 in 26.04) for encrypted deduplication; rsync and tar for mirrors and archives.
Desktop tools note: Déjà Dup is for desktop user files; Timeshift creates local OS rollback snapshots (skipping /home by default) and is not an offsite backup.
Databases: dump MySQL/MariaDB or PostgreSQL logically before copying files.
Automation: use systemd timers for journalctl logs and missed-run catch-up.
Follow the 3-2-1 (and 3-2-1-1-0) Backup Rule
CISA’s backup guidance recommends keeping at least 3 copies of data on 2 different storage media, with 1 copy offsite. To defend against ransomware and compromised admin keys, extend this to 3-2-1-1-0: add 1 immutable or offline copy that the live server cannot delete, and maintain 0 errors via automated checks and restore drills.
The 3-2-1-1-0 Ubuntu backup architecture balancing fast local recovery and immutable offsite protection.
What to Back Up on an Ubuntu Server
Skip virtual kernel filesystems and focus on configuration, application state, and recovery manifests:
Configs & certs:/etc/ (Nginx, Apache, SSH, UFW/nftables, systemd units in /etc/systemd/system/, and /etc/letsencrypt/).
App data & users:/var/www/, /srv/, container volumes, and /home/.
Database dumps: scheduled exports in /var/backups/db/.
Package list: run apt-mark showmanual > /var/backups/apt-manual.txt so you can reinstall software on a clean Ubuntu image.
For full-filesystem mirrors, exclude /dev/*, /proc/*, /sys/*, /tmp/*, /run/*, /mnt/*, /media/*, /lost+found, and /var/cache/*.
Choosing the Right Ubuntu Backup Tool
Match the tool to your recovery goal: quick directory mirrors, portable archives, or encrypted deduplicated offsite repositories.
Comparison of core Ubuntu server backup tools across encryption, deduplication, and offsite support.
1. Incremental Mirroring with rsync
rsync mirrors files quickly while preserving permissions, ACLs, and extended attributes. Store exclusions in a file so scripts work identically under cron, systemd, and interactive shells:
Remember that /etc/ copies directory contents whereas /etc copies the folder itself, and always dry-run (-n) before enabling --delete. For multi-day hardlink snapshots over rsync, see Ubuntu’s rsnapshot guide. Note that rsync encrypts only in transit over SSH, not at rest.
2. Portable Archives with tar
tar is ideal for quick snapshots of /etc before config changes. Keep archives outside web roots and encrypt with gpg --symmetric --cipher-algo AES256 before uploading offsite:
sudo tar --acls --xattrs -czpf /var/backups/etc-$(date +%F).tar.gz /etc
tar -tzvf /var/backups/etc-$(date +%F).tar.gz | head
3. Encrypted SSH Backups with BorgBackup
BorgBackup provides chunk-level deduplication, compression, and client-side encryption. Ubuntu 24.04 ships borgbackup1.2.8 and Ubuntu 26.04 ships 1.4.4 (26.04 also includes borgbackup2 as a 2.0.0b20 beta, so use stable borgbackup 1.x in production):
sudo apt update && sudo apt install -y borgbackup
export BORG_PASSPHRASE="strong-generated-passphrase"
borg init --encryption=repokey-blake2 ssh://borg@backup.example.com:22/srv/borg/web01
borg key export ssh://borg@backup.example.com:22/srv/borg/web01 /root/borg-key.txt
borg create --stats --compression zstd,6 \
ssh://borg@backup.example.com:22/srv/borg/web01::"{hostname}-{now:%Y-%m-%d}" \
/etc /var/www /home /var/backups/db
borg prune --list --keep-daily=7 --keep-weekly=4 --keep-monthly=6 \
ssh://borg@backup.example.com:22/srv/borg/web01
borg compact ssh://borg@backup.example.com:22/srv/borg/web01
4. Encrypted S3 & Cloud Backups with Restic
Restic (0.16.4 in Ubuntu 24.04; 0.18.1 in Ubuntu 26.04) encrypts and deduplicates data natively to S3-compatible buckets, Backblaze B2, SFTP, or rclone:
Déjà Dup targets GNOME desktop folders, not headless servers. Timeshift takes local Rsync or Btrfs system snapshots (also usable via CLI), but excludes /home and /root by default and lacks encrypted offsite storage. Similarly, VPS, LVM, and ZFS snapshots help roll back botched updates quickly, but they live on the same host or cloud account and do not replace independent offsite backups.
Backing Up MySQL, MariaDB, and PostgreSQL Safely
Copying /var/lib/mysql or /var/lib/postgresql on a live server risks inconsistent tables. Export logical dumps into a root-only directory right before your file backup runs:
systemd timers beat bare cron jobs on Ubuntu 24.04 and 26.04 because output goes straight to journalctl and Persistent=true catches missed runs after reboots. Put your backup script at /usr/local/sbin/run-ubuntu-backup.sh (chmod 700) and create a unit pair:
Prefer cron? Call the same script from sudo crontab -e (30 2 * * * /usr/local/sbin/run-ubuntu-backup.sh >/var/log/ubuntu-backup.log 2>&1) rather than putting inline date +%F commands inside crontab.
Securing Backups Against Ransomware
CISA’s #StopRansomware Guide warns that intruders actively delete reachable backups. Lock down your backup targets:
Make offsite storage append-only or immutable: Restrict Borg SSH keys with command="borg serve --append-only --restrict-to-path /srv/borg/web01",restrict, use Restic’s append-only REST server, or enable S3 Object Lock so a compromised host cannot erase past snapshots.
Keep recovery keys off the server: Store Borg key exports and passphrases in a password manager—not only on the host being backed up.
Lock down credential files: Keep /etc/default/ubuntu-backup owned by root:root with permissions 0600.
Verify repository integrity weekly and test real restores into a temporary directory or staging VM quarterly:
# Borg integrity check + test extract
borg check ssh://borg@backup.example.com:22/srv/borg/web01
mkdir -p /tmp/restore-test && cd /tmp/restore-test
borg extract ssh://borg@backup.example.com:22/srv/borg/web01::"web01-2026-11-25" etc/nginx
# Restic integrity check + test restore
restic check --read-data-subset=5%
restic restore latest --target /tmp/restore-test --include /etc/nginx
# Test database restore
gunzip < /tmp/restore-test/var/backups/db/mysql-all-2026-11-25.sql.gz | sudo mysql
sudo -u postgres pg_restore -d mydb_test /tmp/restore-test/var/backups/db/mydb-2026-11-25.dump
FAQ
What is the best Ubuntu backup tool for a production server?
BorgBackup (for SSH servers) and Restic (for S3/cloud object storage) are top choices because both provide client-side encryption, deduplication, and automated pruning.
Should I use Timeshift or Déjà Dup on Ubuntu Server?
Déjà Dup is a desktop app. Timeshift works on the CLI for local OS rollbacks, but it excludes /home and /root by default and does not replace encrypted offsite backups.
Are VPS or cloud snapshots enough?
No. Snapshots live inside the same cloud account and hypervisor; keep an independent encrypted offsite copy under separate credentials.
Why use mysqldump or pg_dump instead of copying /var/lib/mysql?
Copying active database files can capture half-written pages and corrupt tables. Logical dumps produce consistent, restorable snapshots.
How often should I back up an Ubuntu server?
Run encrypted incremental backups at least daily, take an extra snapshot before major upgrades, and dump busy databases hourly or ship WAL/binlogs.
How do I protect Ubuntu backups from ransomware?
Use append-only SSH keys or S3 Object Lock, keep passphrases off the server, and maintain one offline or air-gapped copy.
Last Verified: November 25, 2026. Verified for Ubuntu 24.04 LTS and Ubuntu 26.04 LTS against Ubuntu Server documentation, BorgBackup, Restic, PostgreSQL, systemd, and CISA guidance.