Back to articles
AI & Cloud

Guide to Backing Up Linux VPS with Restic: End-to-End Encryption & Incremental Storage for Enterprises

A detailed guide on using Restic to back up Linux VPS comprehensively with end-to-end encryption and incremental data storage, optimized for enterprise performance, security, and...

DPTCloud Engineering4 min read
Guide to Backing Up Linux VPS with Restic: End-to-End Encryption & Incremental Storage for Enterprises

Image credit: Niewyrazisty · Pixabay Content License

Introduction

Backing up data is a critical component of any enterprise information protection strategy. For Linux-based virtual private servers (VPS), deploying a comprehensive, secure, and efficient backup solution is essential. In this guide, we use Restic, an open-source backup tool, to perform full backups of Linux VPS with key features: end-to-end encryption and incremental data storage. This solution ensures maximum data security and optimizes bandwidth and storage usage, making it ideal for business environments.

Prerequisites and Restic Installation

You need a Linux VPS (Ubuntu/Debian/CentOS) and root or sudo access to proceed.

1. Install Restic

For Ubuntu/Debian:

curl -s https://packagecloud.io/install/repositories/restic/restic/script.deb.sh | sudo bash
sudo apt install restic

For CentOS/RHEL:

curl -s https://packagecloud.io/install/repositories/restic/restic/script.rpm.sh | sudo bash
sudo yum install restic

2. Install OpenSSL (if needed)

Restic uses OpenSSL for end-to-end encryption. Ensure it is installed:

sudo apt install openssl

Setting Up End-to-End Encryption and Incremental Storage

Restic automatically enables end-to-end encryption and stores data incrementally. However, proper configuration is required to maximize these benefits.

1. Initialize the Backup Repository

Choose a storage location for the backup repository (local, S3, WebDAV, etc.). For example, using S3:

restic -r s3:https://s3.amazonaws.com/your-bucket-name init

This command prompts you to enter an encryption password. Store this password securely—it is the key to restoring your data.

2. Configure Environment Variables

To avoid entering login details each time, set the following environment variables:

export RESTIC_REPOSITORY=s3:https://s3.amazonaws.com/your-bucket-name
export RESTIC_PASSWORD=your-strong-password
export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key

3. Run the First Backup

Execute the initial backup:

restic backup /var/www /home /etc --exclude /var/log --exclude /tmp

This backs up critical directories while excluding log and temporary files to reduce storage usage.

Scheduling and Optimizing Regular Backups

To automate backups, create a cron job.

1. Create a Cron Job

Run:

crontab -e

Add the following line to back up daily at 2:00 AM:

0 2 * * * /usr/bin/restic backup /var/www /home /etc --exclude /var/log --exclude /tmp

2. Optimize Performance

  • Exclude unnecessary directories: Skip log, cache, and temporary folders.
  • Backup by partition: Back up key directories separately if needed.
  • Reduce backup size: Use --exclude and --exclude-caches flags.

Verification and Troubleshooting

Ensure your backup process works correctly.

1. Check Backup Status

restic snapshots

Displays all saved backup snapshots.

2. Verify Data Integrity

restic check

Runs a data integrity check on the backup repository.

3. Troubleshooting

  • Cannot connect to repository: Verify network connectivity and S3 access permissions.
  • No backups found: Check cron job execution and user permissions.
  • Incorrect password: Re-enter the correct encryption password.

References

Related infrastructure & engineering guides: Comprehensive Guide to Deploy Hysteria 2 on VPS to Bypass Intl Bandwidth Limits and Reduce Ping

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478