Blog / Tutorials / Back Up a VPS with Restic to S3 Object Storage
(last updated: )

Back Up a VPS with Restic to S3 Object Storage

Restic is a command-line backup tool that encrypts every backup, deduplicates data and writes to any S3-compatible bucket. To back up a VPS with it, install restic, point it at an Object Storage bucket with environment variables, run restic init once, then schedule restic backup…

8 min read
Restic encrypts VPS snapshots and sends deduplicated data to object storage

Restic is a command-line backup tool that encrypts every backup, deduplicates data and writes to any S3-compatible bucket. To back up a VPS with it, install restic, point it at an Object Storage bucket with environment variables, run restic init once, then schedule restic backup with a systemd timer. Test a restore before you trust it.

What Is Restic?

Restic takes snapshots of the folders you choose, and it’s quick to learn, because a handful of commands cover daily use. Each snapshot is split into chunks, encrypted on your server, and only new chunks are uploaded. Run it nightly and the second backup of a 50 GB folder with a few changed files uploads a few megabytes, not 50 GB. That’s why keeping 30 or more snapshots costs little storage.

It’s a single Go binary with backends for local disks, SFTP, S3-compatible storage and more. The repository is always encrypted with a password you set, which is both its best feature and its biggest trap: lose the password and the data is gone for good. Store it in a password manager before you run the first backup.

Restic Backup on Linux: Install and Initialize a Repository

Ubuntu 24.04 and Debian ship restic in their repositories, though the version lags behind what’s on GitHub. Install it with apt, then run restic self-update if you want the current release.

sudo apt update && sudo apt install -y restic
sudo restic self-update
restic version

Restic S3 Setup with Contabo Object Storage

Contabo Object Storage is S3-compatible and uses path-style bucket URLs, so restic works with it through its standard s3 backend. Not every AWS S3 feature may be available, but restic doesn’t need them: basic object reads and writes are enough.

  1. Create a bucket in the Customer Control Panel and note the endpoint URL shown for your storage region.
  2. Create or copy the S3 access key and secret key for the storage.
  3. Put the credentials and the repository address in an environment file that only root can read.
  4. Run restic init, then the first backup.
  5. Run restic snapshots to confirm the snapshot exists.
# /root/.restic-env   (chmod 600)
export AWS_ACCESS_KEY_ID="<your-access-key>"
export AWS_SECRET_ACCESS_KEY="<your-secret-key>"
export RESTIC_REPOSITORY="s3:https://<your-endpoint>/<your-bucket>"
export RESTIC_PASSWORD_FILE="/root/.restic-password"

source /root/.restic-env
restic init
restic backup /etc /opt /home
restic snapshots

Copy the endpoint exactly as the panel shows it. If restic complains about the region, that’s the first thing to check in the Object Storage documentation. Contabo’s docs list the region as default for S3 clients. If you want a deeper look at the service, see our overview of Object Storage, and if you already use rclone, our rclone backup guide shows how the two compare.

Schedule Restic Backups with systemd Timers

Cron works, but a systemd timer gives you logs in journalctl and, with Persistent=true, it runs a missed backup after a reboot. You’ll need two small files, and the timer below fires at 02:30 with up to 15 minutes of random delay.

# /etc/systemd/system/restic-backup.service
[Unit]
Description=Restic backup to Object Storage
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
EnvironmentFile=/root/.restic-env-systemd
ExecStart=/usr/bin/restic backup /etc /opt /home --exclude-caches
ExecStartPost=/usr/bin/restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

# /etc/systemd/system/restic-backup.timer
[Unit]
Description=Nightly restic backup

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

[Install]
WantedBy=timers.target

EnvironmentFile wants plain KEY=value lines without the export keyword, so keep a second copy of the variables in that format. Then run systemctl daemon-reload and systemctl enable –now restic-backup.timer. Check the next run with systemctl list-timers.

Restic Docker Backups: Volumes and Databases

Containers make backups a bit trickier, because a database can be in the middle of a write when restic reads its files. The safe pattern has two steps.

  • Dump each database first, for example docker exec postgres pg_dumpall -U postgres > /opt/backups/postgres.sql, and back up the dump.
  • Back up bind-mounted folders directly. For named volumes, restic can read /var/lib/docker/volumes, though stopping the container for the backup window is the cleanest option for small apps.
  • Run restic itself in a container if you prefer: the restic/restic image takes the same environment variables and mounts the folders read-only.

Skip /var/lib/docker/overlay2 and the image layers. They’re large, easy to rebuild, and they’d eat 10 GB or more of bucket space for nothing.

Restic Backup Retention, Pruning and Restore Tests

Retention decides how far back you can go. Pruning frees the space of snapshots you no longer keep. A policy that suits most small servers looks like this.

Example restic retention and restore checklist Example policy for a small VPS, as of December 2026. Adjust to your recovery needs and storage budget.
ItemSetting or commandWhy
Daily snapshots–keep-daily 7Covers a bad deploy or a deleted file last week
Weekly snapshots–keep-weekly 4Covers a problem noticed after a few weeks
Monthly snapshots–keep-monthly 6Covers slow, quiet corruption
Integrity checkrestic check, weekly; –read-data-subset=5% monthlyFinds damaged data before you need it
Restore testrestic restore latest –target /tmp/restore-test, monthlyA backup you haven’t restored is a guess

The restore test is the one people skip. Do it once now, on the same server, and open a few files. Do it again on a different machine after a month, because that’s what a real recovery looks like.

Restic vs Borg

Borg is the other well-loved backup tool in this space. Both give you encrypted, deduplicated snapshots, so the choice comes down to where you store them.

Restic vs Borg Compared from each project’s public documentation, as of December 2026.
ResticBorg
Storage backendsLocal, SFTP, S3-compatible and more, built inLocal and SSH; no S3 backend, needs a Borg binary on the remote side
EncryptionAlways onOptional, chosen when you create the repository
CompressionSupported in recent versionsStrong options; often better ratios
SpeedGood; depends on backendOften faster over SSH
InstallSingle static binaryPython-based, packages for most distros

If your target is S3 storage, restic is the simpler path. If your target is a server you reach over SSH and you care about compression, Borg is a strong choice.

Why Back Up a Contabo VPS to Object Storage

An off-server copy is the point. If the VPS is deleted, hacked or just broken, a backup on the same disk goes with it, and you’ve lost both copies at once. Object Storage is a separate service from your VPS, S3-compatible, and sold at a flat rate per tier with traffic included, from 2.96 EUR a month as of December 2026. It’s available in Europe, the US and Asia, and it supports versioning and object locking. You can keep several months of snapshots without resizing the server. Check the current price on the Object Storage page before you plan your retention.

A Storage VPS is the other option, reachable over SFTP, and restic supports that too. Before you pick, read our overview of backup strategies and our explanation of incremental and differential backups.

FAQ: Restic Backups

Is restic better than Borg?

Neither wins everywhere. Restic is easier with S3 storage, is always encrypted and is a single binary. Borg often compresses better and runs faster over SSH. If your backups go to an S3 bucket, restic is the more direct choice.

Does restic work with S3-compatible storage?

Yes. Restic has a built-in S3 backend that works with S3-compatible services like Contabo Object Storage. Set the access key, secret key and a repository address such as s3:https://endpoint/bucket, then run restic init.

How often should I back up a VPS?

Once a day works for most servers, with the schedule matched to how much data you can afford to lose. A server with a busy database may need hourly database dumps. Whatever you pick, run a restore test every month.

Can I run restic in Docker?

Yes, with the restic/restic image. Mount the folders you want to back up as read-only volumes and pass the same environment variables for the repository. Dump databases first so the files restic reads are consistent.

Disclaimer: Product specifications, features, and prices mentioned in this article are subject to change and may vary by region, billing term, and active promotions. Please check each provider’s or brand’s official website for current figures, pricing, and local currency rates.