Data integrity is the basis of professional infrastructure management, yet backup strategies often fail because of complexity or high storage costs. In this guide, we will implement a secure and automated Restic backup to Storage VPS, which ensures your data is encrypted, deduplicated, and safely stored off-site.
By combining Restic’s modern snapshot capabilities with a reliable destination like Perlod Hosting, you can create a strong disaster recovery pipeline that guarantees your data is protected against hardware failures, accidental deletions, and security threats.
Prerequisites for Restic Backup to Storage VPS
Before you start the Restic backup to Storage VPS, ensure you have the following resources and proper access to establish a secure connection between your servers:
Source Server: The machine you want to back up, for example, your production server.
Destination Server: A Storage VPS with SSH access.
SSH Key Access: Ensure the source server can SSH into the destination server without a password.
Quick check: You can run the command below from your source server:
Bash
sshuser@storage-vps-ip
If it asks for a password, you must set up SSH keys with ssh-copy-id before you start.
Once you are done with these prerequisites, follow the steps below to complete the Restic backup to Storage VPS.
Install Restic on Source Server
You must install the Restic package on the machine you want to back up. Restic is available in the default repositories of most major Linux distributions.
Then, you can run the Restic self-update command, which is recommended for the latest features:
Bash
resticself-update
Initialize Encrypted Repository on Storage VPS
In this step, you must initialize the storage location on your Storage VPS. This process creates the necessary directory structure for your data and establishes the master encryption keys that will protect your backups from unauthorized access.
First, you must define your repository location string:
Bash
sftp:user@remote_IP:/path/to/backup_folder
Then, you can run the initialization command on your Storage VPS:
At this point, you can create a shell script on your source server to automate the entire backup workflow. This script will handle authentication, perform the backup, and automatically remove old snapshots based on your retention policy to keep your storage usage efficient.
Create the automation script file with the command below:
Bash
nano/usr/local/bin/restic-backup.sh
Paste the following script into the file and edit the VARIABLES section with your details:
Bash
#!/bin/bash# --- VARIABLES ---exportRESTIC_REPOSITORY="sftp:root@192.0.2.100:/var/backups/restic-repo"exportRESTIC_PASSWORD="your-strong-password-here"# List of directories to backupBACKUP_PATHS="/etc /var/www /home"# Retention Policy (Pruning)# Keep: Last 7 days, 4 weeks, and 6 monthsRETENTION="--keep-daily 7 --keep-weekly 4 --keep-monthly 6"# --- COMMANDS ---# 1. Perform Backupecho"Starting Backup..."resticbackup$BACKUP_PATHS--verbose# 2. Prune Old Backups (Forget + Prune)echo"Pruning Old Snapshots..."resticforget$RETENTION--prune# 3. Check Integrity (Optional but recommended periodically)# echo "Checking Repository Integrity..."# restic check
Once you are done, save and close the file.
Make the script executable and restrict permissions since it contains your password:
Bash
chmod700/usr/local/bin/restic-backup.sh
You can test the backup automation script manually with the command below:
Bash
/usr/local/bin/restic-backup.sh
You should see Restic scanning files, uploading blobs, and then cleaning up old snapshots.
Schedule Backups with Systemd
Now that you have a working backup script on the source server, you need to schedule it to run automatically. You can use systemd timers for this task, as they provide superior reliability, logging, and error handling compared to traditional cron jobs, which ensure your critical data is backed up consistently.
Create the service unit file for your Restic backup with the command below:
A backup strategy is incomplete without a tested recovery plan. In this final step, you can use these essential commands on your source server to list your available snapshots, verify the integrity of your repository, and restore your data quickly in the event of data loss.
To mount the repository and browse backups like a file system, you can use:
Bash
mkdir/mnt/resticresticmount/mnt/restic
Now you can browse /mnt/restic/snapshots in your file manager.
You can also automate this verification process with the Bash Automated Backup Integrity Script tutorial to get alerted instantly if a backup is corrupted.
That’s it, you are done with the Restic backup to Storage VPS.
Conclusion
At this point, you have a fully automated and secure backup system. Your data is encrypted and safely sent to your Storage VPS. With systemd handling the scheduling and Restic managing deduplication and automation, your backup strategy is now efficient enough to run daily without impacting performance.
Just remember to test a restore to ensure your disaster recovery plan is always ready for action.
We hope you enjoy this guide on Restic backup to Storage VPS. Subscribe to our X and Facebook channels to get the latest updates and articles.
No. Restic is smart; it only uploads the parts of files that have changed. This makes daily backups extremely fast and saves space on your Storage VPS.
This usually means a previous backup didn't finish properly. You can fix it easily by running the unlock command: restic -r sftp:user@remote_IP:/path unlock.
Yes. You can back up multiple servers to one Storage VPS. If they share the same repository, Restic will even deduplicate data between them to save extra space.
We use cookies to run PerLod and to understand how the site is used. You can accept everything, or open Manage to turn individual categories off. Cookie policy.