On this pageMap what you store
One VPS can hold a small company's shared files, its application databases and its internal tools. The server itself is rarely what fails a business. What fails is the missing plan: an account with more access than anyone remembers, a backup that was never restored, data nobody knew was there. This guide builds that plan in five parts: an inventory, access control, encryption, backups with restic, and restore drills.
Map what you store
You cannot protect data you have not listed. Start with a table like this one and keep it next to the server's documentation:
| Data | Where it lives | Who needs it | Cost of losing it | Keep for |
|---|---|---|---|---|
| Customer database | PostgreSQL, database shop |
The app, two admins | Business stops | Contract length plus legal minimum |
| Shared documents | /srv/files |
All staff | Days of rework | Per document policy |
| Invoices | /srv/invoices |
Finance | Legal exposure | What your tax rules require |
| Logs | /var/log |
Admins | Low | 30 to 90 days |
The "cost of losing it" column sets how often each item is backed up. The "keep for" column becomes your retention and deletion schedule, and it applies to backups as much as to live data.
Control who can reach what
People log in with their own keys
Give every person a named account with an SSH key, and turn password logins off. On Ubuntu, a file in /etc/ssh/sshd_config.d/ does it; name it so it sorts before 50-cloud-init.conf, because sshd keeps the first value it reads:
echo 'PasswordAuthentication no' | sudo tee /etc/ssh/sshd_config.d/10-no-passwords.conf
sudo sshd -t && sudo systemctl reload ssh
Keep a second session open while you test, so a mistake cannot lock you out. When someone leaves, delete their account and key the same day.
Files belong to groups, not to people
A group per team keeps access readable at a glance. The setgid bit (the 2 in 2770) makes new files inherit the folder's group:
sudo groupadd finance
sudo usermod -aG finance maria
sudo install -d -o root -g finance -m 2770 /srv/invoices
Applications get their own database users
Each application connects with a database user that can touch only its own database, and no application uses the superuser. Databases listen on localhost, and the firewall admits only SSH and HTTPS. On CloudSat, a cloud firewall adds that filter in front of the server, and two-factor authentication protects the account that could delete the server outright.
Encrypt what leaves the server
In transit, use SSH or SFTP for administration, HTTPS for web applications, and WireGuard or TLS whenever a database connection crosses a network.
At rest, full-disk encryption on a VPS has a practical catch: the key must be typed at every boot through the console, or stored on the server, where it protects little. Put the effort where data actually travels: backups. restic encrypts every backup with AES-256 on the server before anything is uploaded, so the storage provider only ever sees ciphertext.
Backups: 3-2-1 for a single server
Keep three copies of the data, on two different storage systems, with one copy off-site. For one VPS, that means the live data, a provider snapshot, and a restic repository somewhere else. On CloudSat, snapshots cover the second copy for quick rollbacks, and a small server in another of the 13 regions can hold the third.
Set up restic
Ubuntu 26.04 packages restic 0.18.1, which has everything used below. Ubuntu 24.04 ships 0.16.4, older than the --stdin-from-command option added in 0.17, so install a current release from the restic project's GitHub releases there. Then, as root (sudo -i):
apt install restic
install -m 600 /dev/null /root/.restic-pass
openssl rand -base64 32 > /root/.restic-pass
export RESTIC_REPOSITORY=sftp:backup@198.51.100.50:/srv/restic/app01
export RESTIC_PASSWORD_FILE=/root/.restic-pass
restic init
Root needs an SSH key accepted by the backup user on the target server. Copy the repository password into your password manager now: without it, the backups cannot be decrypted by anyone, including you.
Back up databases as dumps, not files
Copying the data directory of a running database can capture it mid-write. Use the database's own dump tool and stream the output into restic. With --stdin-from-command, a failing dump cancels the snapshot instead of saving a broken file:
restic backup /etc /srv --exclude-caches
restic backup --stdin-filename shop.dump --stdin-from-command -- \
sudo -u postgres pg_dump -Fc shop
restic backup --stdin-filename crm.sql --stdin-from-command -- \
mariadb-dump --single-transaction --routines --triggers crm
--single-transaction gives a consistent MariaDB dump of InnoDB tables without locking out the application.
Schedule, prune and check
Put the commands in a script and run it nightly:
#!/bin/sh
set -eu
export RESTIC_REPOSITORY=sftp:backup@198.51.100.50:/srv/restic/app01
export RESTIC_PASSWORD_FILE=/root/.restic-pass
restic backup /etc /srv --exclude-caches
restic backup --stdin-filename shop.dump --stdin-from-command -- sudo -u postgres pg_dump -Fc shop
restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune
restic check --read-data-subset=5%
Save it as /usr/local/sbin/backup.sh, make it executable, and add 30 2 * * * root /usr/local/sbin/backup.sh >> /var/log/restic.log 2>&1 to /etc/cron.d/restic. The forget line is your retention policy in code: seven daily, four weekly and twelve monthly snapshots. check verifies a random 5% of the stored data on every run. Finish the script by pinging a dead-man's-switch monitor, so a night without a successful run raises an alert instead of silence.
One step further: if an attacker takes over the server, they hold the backup credentials too and can delete the backups. Serving the repository with restic's rest-server in --append-only mode prevents that; pruning then runs on the backup server itself.
Restore drills
A backup counts once it has been restored. Once a month, and after every change to the setup, restore something real:
restic snapshots
restic restore latest --path /srv --target /tmp/restore-test --include /srv/invoices
restic dump --path /shop.dump latest shop.dump > /tmp/shop.dump
sudo -u postgres createdb shop_restore_test
sudo -u postgres pg_restore -d shop_restore_test /tmp/shop.dump
Open a few restored files, count rows in a couple of tables, then drop the test database and delete the files. Write down how long the full restore took: that number is your real recovery time, whatever anyone promised.
The compliance basics
This is not legal advice, but most data-protection rules ask a small business for the same habits:
- Know where data lives. Pick a server region that matches your obligations, and remember that off-site backups count: a copy in another country is still a transfer.
- Delete on schedule. Your inventory's "keep for" column must match the
forgetpolicy. Data deleted from the live system survives in backups until those snapshots expire, so document that delay. - Keep access records. SSH logins and application audit logs show who touched what, if you keep them long enough to look.
- Write it down. One page with the inventory, the people with access, where backups go and how to restore them is worth more than any tool.
FAQ
Are provider snapshots enough on their own?
No. Snapshots are excellent for rolling back a failed upgrade, but they live with the same provider and are managed from the same account as the server. Keep at least one copy that an account problem cannot reach.
How often should I back up?
As often as the "cost of losing it" column demands. Nightly suits most files. A database that changes all day may need hourly dumps, or point-in-time recovery with WAL archiving through tools such as pgBackRest or WAL-G.
What happens if I lose the restic password?
The repository becomes unreadable, permanently. There is no reset. Keep the password in a password manager and in a sealed offline copy, and test that both work.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




