Skip to content

VPS Backup Guide: Create, Verify and Restore Safely

November 26, 2026 ARPHost Uncategorized

A backup stays unproven until you extract it into an isolated sandbox, verify file and database integrity, and time the full recovery against your downtime limit. That test exposes the failures green status hides: missing config files, broken database dumps, oversized restores, and restore steps nobody has practiced.

Start by proving your current archive works with a timed restore to a scratch directory:

time restic restore latest --target /srv/restore-test

Compare the restored tree against what the job was supposed to protect. Check permissions, ownership, application config paths, and database artifacts before you trust the archive. If you can't run that test and validate the output cleanly, you have storage bills rather than a recovery plan.

Backup operations work as an ongoing cycle of running, maintaining, and testing restores. U.S. National Institute of Standards and Technology (NIST) recommendations for managed service providers belong in that broader discipline, but the operational rule stays simple: schedule the backup, schedule the restore test, record the elapsed time, and fix the procedure before production depends on it.

Table of Contents

Pick the Backup Method Your VPS Actually Needs

A reliable VPS backup keeps at least three copies of your data across two different storage types, with one copy stored completely off the VPS, and the right method hinges on what you need to rebuild. Most Linux operators combine three layers: an image-level copy for fast full-server rebuilds, a deduplicated file-level archive with restic or borg for configs and web roots, and a logical database dump for transaction safety. Follow CISA small and medium business backup guidance, which advises scheduled full and partial recovery tests alongside the ability to roll back at least seven days.

MethodWhat it capturesTypical recovery pointRestore granularityMain weakness
Provider snapshotWhole disk at hypervisor levelSet by provider, often dailyWhole VM onlyTied to provider retention limits and account access rules
Image-level backup to a backup serverWhole VM in incremental chunksHourly to dailyWhole VM or single fileNeeds separate storage and a retention policy
File-level archive (restic or borg)Chosen directories and configsHourly to dailyIndividual files and foldersMisses anything not in the chosen paths
Database dump (mysqldump or pg_dump)Logical copy of each databaseHourly to dailyIndividual databases or tablesInconsistent unless dumped with transaction-safe options
Config and secrets exportWeb server, service and key filesOn every changeIndividual filesEasy to forget after a configuration change

Why Snapshots Alone Fall Short

A hypervisor snapshot sitting on the same physical node or storage pool isn't an independent backup. If the underlying array fails, a control panel credential leaks, or an operator deletes the wrong volume, the production VM and its snapshot disappear together.

Even when an image-level copy leaves the host for an off-site server, it still doesn't replace a logical database dump. Copying raw disk blocks while MariaDB, MySQL, or PostgreSQL is flushing dirty pages can capture half-written transactions that leave the database unable to mount cleanly on boot.

We encourage clients to keep their own independent backups alongside our backup solutions on our VPS hosting platform. With our Proxmox Backup service, you configure what gets backed up and set the schedule, and the service handles the runs automatically. Before writing a single script, write down your acceptable recovery point objective (RPO) and recovery time objective (RTO) for each workload, pick the combination above that meets both targets, and assign one named person to verify job logs and execute restore drills.

How to Build a Scheduled Backup Job on Linux

This workflow targets a Debian 12 or Ubuntu 24.04 server running restic 0.16.0 or newer, writing encrypted archives over SFTP to a separate backup host or an S3-compatible object store. You'll need root SSH access, a configured SSH key alias (backup-host) pointing to your remote storage server, and a MariaDB or MySQL client installed.

A well-structured backup job separates credentials, dumps databases cleanly, and runs under systemd rather than an ad-hoc root script.

A professional developer sitting at a desk and coding on a laptop next to server hardware equipment.

  1. Install restic and verify the version. Older distro packages sometimes lack newer pruning and verification improvements, so confirm you're running 0.16.0 or newer before initializing a repository.
apt update && apt install -y restic
restic version
  1. Isolate backup credentials and lock down the repository password. Create a dedicated user on your remote backup target that has no login access to production, then store your encryption passphrase in /root/.restic-pass with 600 permissions. A password file readable by the web server user (www-data) exposes your entire archive if a web app gets compromised, and because restic encrypts all data by default, copy that passphrase into an off-server password manager immediately.
umask 077
printf '%sn' 'REPLACE_WITH_LONG_RANDOM_PASSPHRASE' > /root/.restic-pass
chmod 600 /root/.restic-pass
  1. Initialize the remote repository. Export your repository target and password path, run restic init, and confirm the repository ID prints cleanly so you know SSH auth and target permissions work before scripting anything.
export RESTIC_REPOSITORY="sftp:backupuser@backup-host:/srv/restic-repo"
export RESTIC_PASSWORD_FILE="/root/.restic-pass"
restic init
  1. Create a consistent database dump script. Build /usr/local/sbin/backup-vps.sh so it dumps databases into /var/backups/db with --single-transaction --routines before archiving files. Skipping transaction-safe flags on an active InnoDB table produces a dump that restores with mismatched rows or foreign-key errors.
cat <<'EOF' > /usr/local/sbin/backup-vps.sh
#!/usr/bin/env bash
set -euo pipefail

export RESTIC_REPOSITORY="sftp:backupuser@backup-host:/srv/restic-repo"
export RESTIC_PASSWORD_FILE="/root/.restic-pass"

mkdir -p /var/backups/db
chmod 700 /var/backups/db

mysqldump --single-transaction --routines --all-databases > /var/backups/db/all-databases.sql

restic backup --tag daily /etc /var/www /var/backups/db
restic forget --keep-daily 7 --keep-weekly 4 --prune
EOF
chmod 700 /usr/local/sbin/backup-vps.sh
  1. Run the first backup manually. Execute /usr/local/sbin/backup-vps.sh once from the shell to catch missing paths, SSH host-key prompts, or MySQL auth issues while you're watching the terminal.
/usr/local/sbin/backup-vps.sh

Scheduling and Verifying the Systemd Timer

  1. Wire the script into a systemd service and timer. Place the job at 02:30 server time with Persistent=true. Unlike a standard entry explained in our breakdown of cron job scheduling, a persistent systemd timer automatically fires a missed backup after an unexpected reboot and streams every line of output straight into journald.
# /etc/systemd/system/backup-vps.service
[Unit]
Description=Encrypted VPS backup to offsite restic repository
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/backup-vps.sh
# /etc/systemd/system/backup-vps.timer
[Unit]
Description=Run VPS backup daily at 02:30

[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true

[Install]
WantedBy=timers.target
  1. Enable the timer and confirm execution. Reload systemd, enable the timer, verify the next scheduled trigger, and inspect the exit status in journalctl after the first run.
systemctl daemon-reload
systemctl enable --now backup-vps.timer
systemctl list-timers --all | grep backup-vps
systemctl status backup-vps.service --no-pager
journalctl -u backup-vps.service -n 30 --no-pager

Production observation: On multi-tenant VPS hosts, scheduling heavy dump and compression jobs right at midnight often collides with neighboring guests running default logrotate and backup tasks. Shifting your timer to an off-minute window like 02:30 keeps disk wait low and prevents random backup timeouts.

Retention Rules and Reclaiming Backup Space

Short retention windows save a few gigabytes of storage right up until you discover an attacker entered your server three weeks ago. If you only keep seven daily copies, every surviving snapshot already contains the backdoor. Designing layered retention lets you recover quickly from yesterday's accidental deletion while still reaching back months for a clean baseline.

In restic, retention happens in two stages inside one command: restic forget drops snapshot references that fall outside your policy, and --prune removes pack data that no remaining snapshot needs.

restic forget --keep-last 3 --keep-daily 7 --keep-weekly 4 --keep-monthly 3 --prune
restic snapshots

Don't add those flags together and expect 17 snapshots on disk. A single snapshot taken at the end of a month can satisfy the daily, weekly, and monthly rules at the same time, so the surviving count is often smaller than the sum of the options.

Retention ruleWhat it keepsWorked example
--keep-last 3The three most recent snapshots regardless of ageLast three runs, even if all are from one day
--keep-daily 7One snapshot for each of the last seven days with a backupSeven most recent backup days
--keep-weekly 4One snapshot for each of the last four weeks with a backupFour most recent backup weeks
--keep-monthly 3One snapshot for each of the last three months with a backupThree most recent backup months
Combined daily 7, weekly 4, monthly 3Snapshots matching any ruleUp to 14 snapshots, fewer when one satisfies several rules

Pruning and Garbage Collection on Proxmox Backup Server

Hypervisor-level targets handle cleanup differently from file-level archives. According to the Proxmox Backup Server storage documentation, Proxmox Backup Server (PBS) configures retention by time intervals rather than a single maximum snapshot count: a datastore independently retains hourly, daily, weekly, monthly, and yearly snapshots, plus a time-independent count. Because one snapshot can satisfy multiple rules, a policy of keep-daily 7, keep-weekly 4, and keep-monthly 3 doesn't always total 14 snapshots, and you should verify pruning against your real backup calendar rather than guessing from flag names.

Space reclamation on PBS is also explicitly split into two operations. As detailed in the Proxmox Backup Server maintenance documentation, pruning only deletes index references for expired snapshots while content-addressed data chunks remain on disk until garbage collection identifies and removes unused chunks. A datastore that still looks full right after a prune job hasn't failed; it hasn't run garbage collection yet.

proxmox-backup-manager garbage-collection start store1
proxmox-backup-manager garbage-collection status store1

Schedule garbage collection a few hours after pruning during a low-load window, since walking the chunk store adds storage I/O that can slow active VM backups. Our Proxmox Backup service works directly with Proxmox VE or an existing Proxmox Backup Server, so these same retention and garbage collection sequences govern disk usage when you offload VM archives. Whatever target you run, keep at least one monthly copy spanning several months so delayed ransomware discovery never forces you to rebuild from scratch.

Verify Backups With a Test Restore

A globally scoped 2021 Veeam CXO research survey conducted by Vanson Bourne reported that 58% of backups failed and 58% of recoveries failed, while 14% of data was not backed up at all. Treating a silent nightly email as proof of recoverability is how outages stretch from hours into days. Every backup repository needs scheduled verification that reads real data and extracts it onto disk.

Start by listing snapshots to verify the newest timestamp sits within your RPO, then sample repository pack files to catch silent bit rot on the target disk:

restic snapshots --latest 3
restic check --read-data-subset=5%

A healthy repository prints verification progress and ends cleanly:

using temporary cache in /tmp/restic-check-cache-39104821
create exclusive lock for repository
load indexes
check all packs
check snapshots, trees and blobs
read 5.0% of data packs
no errors were found

Next, time a full extraction into a dedicated scratch directory and compare file counts and sample checksums against your live paths:

rm -rf /srv/restore-test && mkdir -p /srv/restore-test
time restic restore latest --target /srv/restore-test
find /srv/restore-test/var/www -type f | wc -l
sha256sum /etc/nginx/nginx.conf /srv/restore-test/etc/nginx/nginx.conf

Realistic timing output gives you a baseline for file extraction speed before you even touch a database:

restoring <Snapshot 8a1f3c2d of [/etc /var/www /var/backups/db]> to /srv/restore-test

real    1m42.18s
user    0m18.44s
sys     0m09.12s

Validating Databases and Logging Recovery Metrics

Extracting a .sql file proves you have bytes on disk, not that the dump imports cleanly. Spin up an isolated sandbox VM or a Linux network namespace with zero route to production, import the restored dump into a fresh MariaDB or MySQL instance, and run an integrity check across every table:

mysql < /srv/restore-test/var/backups/db/all-databases.sql
mysqlcheck --all-databases --check

Record four concrete numbers in a plain text runbook or ticket log after every drill:

  • Snapshot age: Confirm the latest snapshot timestamp falls inside your RPO window.
  • Restore duration: Combine file extraction time and database import time, then measure the total against your RTO.
  • Database check result: Log whether mysqlcheck reported OK on every table or flagged crashed indexes.
  • Malware scan result: Record the exit status from scanning the restored web root (for example with clamscan) so you aren't rehearsing a clean restore of an infected site.

If the timed recovery exceeds your RTO, fix the bottleneck now by increasing target bandwidth, switching to faster NVMe scratch storage, or splitting static media out of your critical app snapshot.

Run a single-file restore every month and a full-VM rebuild every quarter. File extraction and full-system boot fail in completely different ways, and testing only one hides broken bootloaders, missing kernel modules, or unbootable fstab mounts.

How to Restore a VPS Without Overwriting Production

Restore beside production, never on top of it. Writing an archive directly over a live server destroys forensic logs you need to trace an intrusion, and if the restore stalls halfway through, you lose both the damaged system and your fallback.

Inspecting physical or virtual staging resources before cutting traffic keeps a recovery orderly when pressure is high.

A technician connects a blue Ethernet cable to a server in a rack for data restoration.

  1. Freeze production writes. Put your web application into maintenance mode and stop incoming database writes so customer orders or form submissions aren't lost in the gap between the old host and the rebuilt one.

  2. Select the last clean snapshot. List tagged archives and inspect timestamps carefully. During a security incident, pick the snapshot taken before the earliest suspected compromise rather than grabbing the newest run automatically.

restic snapshots --tag daily
  1. Extract to a staging path or fresh standby VPS. Pull the chosen snapshot ID onto a clean target disk so production stays untouched.
restic restore 8a1f3c2d --target /srv/restore
  1. Import the database and check application health. Load /srv/restore/var/backups/db/all-databases.sql into a fresh database daemon on the standby host, start your application services, and run your built-in health or schema checks.

  2. Audit configs and rotate every secret. Inspect restored web server configs, SSH authorized_keys, and service units for unauthorized edits. Rotate database passwords, API tokens, and SMTP credentials before going live, because secrets pulled from a pre-incident snapshot may already be compromised.

  3. Pause background side effects and test internally. Before pointing any traffic at the standby VPS, disable scheduled cron jobs and hold outbound mail queues (systemctl stop postfix) so the restored box doesn't double-send invoices or customer notifications. Test the site locally using a workstation hosts file override against the standby server's internal address so you can click through login, checkout, and uploads privately.

  4. Cut over cleanly. For planned recoveries, lower your DNS TTL a day ahead of time. Once internal tests pass, switch the record to the verified standby host, re-enable cron and mail services, and watch your access and error logs in real time.

For a visual walkthrough of staging a safe virtual machine recovery alongside a live environment, watch this demonstration before your next drill.

Rollback Procedure During a Failed Cutover

Keep the original production disk powered down or untouched for at least 72 hours after cutover. If unexpected application errors or missing records appear under live traffic, point the DNS record straight back to the original server to stop the bleeding while you diagnose the gap. If the restored VPS freezes or loses SSH access during validation, use the remote reboot capability through the client portal, alongside your secure remote access tools and real-time monitoring, to recover control without risking the original production volume.

Restore Failures and How to Fix Them

The most frequent failure engineers hit after a restore is a database daemon that refuses to start. You bring up the rebuilt VPS, run systemctl status mariadb, and watch InnoDB crash in a loop because the underlying backup captured open files mid-write without transaction isolation. Most backup and restore failures follow five predictable patterns.

SymptomLikely causeFix
Restored database will not startDump taken during writes without --single-transactionRe-dump with --single-transaction --routines and restore to a sandbox first
restic check reports missing pack filesInterrupted prune or unreliable backup targetFreeze pruning, copy the repository, then run restic check --read-data
Backup succeeds but archive is far smaller than usualSource path not mounted or emptyVerify mount points before the job and fail when size drops below the prior run
Datastore still full after pruningGarbage collection has not runRun proxmox-backup-manager garbage-collection start on the datastore and check its status
Backup never runsTimer created but not enabledRun systemctl enable --now on the backup timer and confirm the next trigger with systemctl list-timers

Fixes split cleanly by turnaround time. Enabling a disabled systemd timer (systemctl enable --now backup-vps.timer) or launching garbage collection takes minutes and gives immediate feedback in logs. Fixing a broken database dump flag or repairing an unmounted path requires waiting for a fresh backup cycle to finish and then re-running your sandbox restore to prove the new archive is clean.

Add a lightweight size-guard check directly inside /usr/local/sbin/backup-vps.sh right after mysqldump so an empty export aborts the job and triggers an alert before bad history piles up:

DUMP_FILE="/var/backups/db/all-databases.sql"
PREV_SIZE_FILE="/var/backups/db/.prev-size"
CURR_SIZE=$(stat -c%s "$DUMP_FILE")

if [ -f "$PREV_SIZE_FILE" ]; then
  PREV_SIZE=$(cat "$PREV_SIZE_FILE")
  MIN_SIZE=$(( PREV_SIZE * 70 / 100 ))
  if [ "$CURR_SIZE" -lt "$MIN_SIZE" ]; then
    echo "ERROR: Dump size $CURR_SIZE dropped below 70% of previous run ($PREV_SIZE)" >&2
    exit 1
  fi
fi

echo "$CURR_SIZE" > "$PREV_SIZE_FILE"

In production: An unmounted secondary block volume rarely breaks a file-level backup job. The script happily archives an empty mount directory, logs a clean exit code, and drops the archive from 40 GB to 4 KB while sending green status emails until someone needs a restore.

When to Escalate a Failing Repository

Never try to brute-force repair a damaged repository in place while automated cleanup is still active. If restic check fails on two consecutive runs, immediately disable your prune schedule so surviving chunks aren't deleted, mirror the raw repository directory to a second storage target, and open a support ticket containing the full restic check output, the repository ID, and the complete output of restic snapshots.

Schedule Your First Restore Test This Week

Pick one production service holding real customer or business records and run the timed sandbox restore workflow against it before Friday. Log the snapshot age, total restore duration, and database integrity output, then cross-check every step against our disaster recovery testing checklist. Put monthly single-file restores and quarterly full-VM rebuilds onto a recurring team calendar, and update your runbook after every drill.

If the test misses your RTO, adjust the backup schedule, upgrade target bandwidth, or streamline your restore path now rather than during an outage. For teams that want multiple virtual server support, replication from a PBS server, incremental and full backups, completely managed storage, immutable backups, and encrypted backups without babysitting timers and recovery drills in-house, our managed services cover Proxmox and VPS operations end to end.


ARPHost, LLC delivers NVMe VPS hosting, Proxmox private clouds, Proxmox Backup as a Service with immutable encrypted storage, and 24/7 U.S.-based managed operations from our Tampa, Florida facility. If you want dependable offsite replication, rapid VM restoration, and infrastructure engineers who treat verified recoverability as standard practice, explore our backup and hosting platforms at ARPHost, LLC.

Tags: , , , ,

Leave a Reply