How to Back Up Linux Servers to Backblaze B2 with Restic and Rclone (Encrypted, Automated, Pruned)

Summary: This guide shows how to back up a Linux server to Backblaze B2 using Restic with Rclone as the transport. You will set up encryption, implement a retention policy, automate runs with systemd timers, and test restores. The result is a fast, encrypted, and low-cost off-site backup that you control.

Why Restic + Rclone + Backblaze B2?

Restic is a modern, deduplicating backup tool with built-in encryption. Rclone provides wide storage compatibility and reliable transfers. Backblaze B2 offers affordable object storage with per-GB pricing. Together, they form a portable, verifiable, and cost-effective backup solution that works on any Linux distribution.

Prerequisites

- A Linux server (Ubuntu/Debian/RHEL/AlmaLinux, etc.) with sudo/root access
- Backblaze B2 account
- Basic terminal familiarity

Step 1: Create a B2 Bucket and Key

1) In Backblaze, create a bucket (e.g., mycompany-backups). Leave it private.
2) Create an Application Key restricted to that bucket. Copy the KeyID and Application Key now; you will not see the secret again.

Step 2: Install Restic and Rclone

sudo apt update && sudo apt install -y restic rclone

On RHEL/Fedora-based systems:
sudo dnf install -y restic rclone

Step 3: Configure Rclone for B2

We will keep Rclone’s config out of your home directory for clarity.

sudo mkdir -p /etc/rclone
sudo chmod 750 /etc/rclone

sudo rclone config create b2 b2 account <KeyID> key <ApplicationKey> hard_delete true --config /etc/rclone/rclone.conf

Verify the config:

sudo rclone lsd b2: --config /etc/rclone/rclone.conf

Step 4: Initialize the Restic Repository (via Rclone)

Create a password file and initialize the repository path inside the bucket.

sudo mkdir -p /etc/restic
echo "choose-a-strong-long-passphrase" | sudo tee /etc/restic/password > /dev/null
sudo chmod 600 /etc/restic/password

Initialize:

sudo env RCLONE_CONFIG=/etc/rclone/rclone.conf restic -r rclone:b2:mycompany-backups/restic --password-file /etc/restic/password init

Step 5: Exclusions and Environment File

Define what not to back up (caches, runtime, VM disks, etc.).

sudo tee /etc/restic/excludes.txt > /dev/null <<'EOF'
/proc/**
/sys/**
/dev/**
/run/**
/tmp/**
/var/tmp/**
/var/cache/**
*.iso
*.img
*.qcow2
EOF

Create an environment file to avoid repeating flags:

sudo tee /etc/restic/restic.env > /dev/null <<'EOF'
RESTIC_REPOSITORY=rclone:b2:mycompany-backups/restic
RESTIC_PASSWORD_FILE=/etc/restic/password
RCLONE_CONFIG=/etc/rclone/rclone.conf
RESTIC_CACHE_DIR=/var/cache/restic
EOF
sudo mkdir -p /var/cache/restic && sudo chown root:root /var/cache/restic && sudo chmod 700 /var/cache/restic

Step 6: Create a Backup Script

This script performs a backup, applies retention, and verifies the repository.

sudo tee /usr/local/bin/restic-backup.sh > /dev/null <<'EOF'
#!/usr/bin/env bash
set -euo pipefail

# Sources to back up (adjust to your server)
SOURCES=(/etc /home /var/www)

# Nice/ionice to reduce system impact
nice -n 10 ionice -c2 -n7 \

env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) \\
restic backup "${SOURCES[@]}" --exclude-file /etc/restic/excludes.txt --tag scheduled --one-file-system

# Retention policy: keep last 7 daily, 4 weekly, 6 monthly
env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) \\
restic forget --prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --tag scheduled

# Optional consistency check (weekly via timer, or keep here for every run)
env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) restic check --read-data-subset=1/20 || true
EOF
sudo chmod 750 /usr/local/bin/restic-backup.sh

Step 7: systemd Service and Timer

Create a systemd unit to run the script, and a timer to schedule it daily.

sudo tee /etc/systemd/system/restic-backup.service > /dev/null <<'EOF'
[Unit]
Description=Restic backup to Backblaze B2 (via rclone)
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
EnvironmentFile=/etc/restic/restic.env
ExecStart=/usr/local/bin/restic-backup.sh
Nice=10
IOSchedulingClass=best-effort
IOSchedulingPriority=7
PrivateTmp=yes
NoNewPrivileges=yes
ProtectSystem=full
ProtectHome=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes

[Install]
WantedBy=multi-user.target
EOF

sudo tee /etc/systemd/system/restic-backup.timer > /dev/null <<'EOF'
[Unit]
Description=Daily Restic backup timer

[Timer]
OnCalendar=03:15
RandomizedDelaySec=20m
Persistent=true

[Install]
WantedBy=timers.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now restic-backup.timer

Step 8: First Run and Verification

Trigger a manual run and watch the output:

sudo systemctl start restic-backup.service
sudo journalctl -u restic-backup.service -n 200 -f

List snapshots to confirm:

sudo env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) restic snapshots

Step 9: Tune Retention and Costs

Adjust the restic forget policy to meet recovery objectives and budget. More aggressive pruning reduces storage but limits historical versions. Backblaze B2 costs depend on stored GB, transaction counts, and egress; deduplication in Restic helps keep usage low.

Step 10: Test a Restore

Never trust backups you have not restored. Create a temporary restore folder and recover a small file.

sudo mkdir -p /tmp/restore-test
sudo env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) restic restore latest --target /tmp/restore-test --include /etc/hostname
ls -l /tmp/restore-test/etc/hostname

Security Best Practices

- Use a long, unique Restic password stored in a root-only file.
- Restrict the Backblaze Application Key to one bucket with minimal permissions.
- Enable MFA on your Backblaze account.
- Keep /etc/rclone/rclone.conf and /etc/restic/password mode 600 and owned by root.
- Consider server-side encryption on B2 as a secondary layer if required by policy, although Restic already encrypts data client-side.

Performance Tips

- Parallel uploads: Restic auto-tunes, but you can increase concurrency on bigger servers via RESTIC_OPTIONS like --jobs 4 for backups or use Rclone env vars (RCLONE_B2_UPLOAD_CONCURRENCY).
- Bandwidth limits: Add --limit-upload 4MiB to Restic, or --bwlimit via Rclone if needed.
- Exclude large/ephemeral paths to reduce churn.

Troubleshooting

Fatal: wrong password or no key found: The password in /etc/restic/password does not match the repository. Fix the password file or re-init a new repo.

Repository locked: A previous run crashed. Remove stale locks only when you are certain no job is running:
sudo env $(grep -v '^\s*#' /etc/restic/restic.env | xargs) restic unlock

Slow uploads or timeouts: Check outbound bandwidth, raise concurrency, and ensure your firewall allows long-lived HTTPS connections. Try adding a randomized delay (already in the timer) to avoid contention on shared links.

What You Achieved

You now have an automated, encrypted, off-site backup pipeline for Linux using Restic, Rclone, and Backblaze B2. Snapshots are deduplicated, retention is enforced, and restores are provable. Regularly verify snapshots, monitor storage usage, and adjust policies as your data grows.

How to Set Up Rclone for Secure Cloud File Synchronization on Linux

Introduction

Cloud storage is an essential part of modern workflows, allowing users to access files from anywhere and back up important data securely. However, managing multiple cloud services can be a challenge, especially on Linux systems. Rclone is a powerful command-line tool that simplifies the process of syncing files and directories to and from dozens of cloud storage providers. This tutorial will guide you through installing Rclone on Linux, configuring it for cloud synchronization, and automating your backups.

Step 1: Installing Rclone on Linux

To get started, you need to install Rclone. Most Linux distributions offer Rclone in their package repositories, but it's best to install the latest version directly from the official website.

Open your terminal and run the following command to download and install Rclone:

curl https://rclone.org/install.sh | sudo bash

After installation, verify the Rclone version:

rclone --version

You should see the installed version number, confirming that Rclone is ready for use.

Step 2: Configuring a Cloud Storage Remote

Rclone supports a wide range of cloud providers, including Google Drive, Dropbox, OneDrive, S3, and many more. To connect to a cloud service, you need to create a new "remote" configuration.

Run the configuration command:

rclone config

Follow the interactive prompts:

  • Type n to create a new remote.
  • Enter a name (e.g., mydrive).
  • Select your cloud provider from the list.
  • Follow the authentication steps, which may include opening a browser and logging in.
  • Once complete, save and exit the configuration tool.

Your cloud remote is now ready for syncing files between Linux and your chosen cloud provider.

Step 3: Syncing Files with Rclone

With your remote configured, you can now sync files. For example, to sync your local Documents folder with the root directory of your cloud drive:

rclone sync ~/Documents mydrive:/Documents

This command copies any new or changed files from your local folder to the cloud. To sync in the opposite direction, simply switch the source and destination.

You can also use the copy command to transfer files without deleting anything from the destination:

rclone copy ~/Pictures mydrive:/Pictures

Step 4: Automating Backups with Cron

To automate your backups, use cron to schedule regular sync operations. Edit your crontab with:

crontab -e

Add a line like the following to run a sync every day at 2 AM:

0 2 * * * rclone sync ~/Documents mydrive:/Documents

This ensures your files stay up-to-date without manual intervention.

Conclusion

Rclone is an invaluable tool for Linux users who want reliable, flexible, and secure cloud file synchronization. With its broad support for cloud providers and automation capabilities, you can safeguard your data and streamline your workflow. Experiment with Rclone's advanced features, such as encryption and bandwidth throttling, to further optimize your cloud backup strategy.

3.

How to Set Up and Use Rclone for Secure File Synchronization Between Cloud Services

Introduction

Rclone is a popular open-source command-line tool that allows users to sync files and directories between different cloud storage providers such as Google Drive, Dropbox, OneDrive, Amazon S3, and many others. As organizations and individuals increasingly rely on multiple cloud services, efficient synchronization and backup solutions have become essential. In this tutorial, you will learn how to install Rclone, configure it with your preferred cloud provider, and perform basic file synchronization tasks securely and efficiently.

Step 1: Installing Rclone

Rclone supports Linux, Windows, and macOS. For most users, the easiest way to install Rclone is by downloading the precompiled binary. On Linux, open your terminal and run:

curl https://rclone.org/install.sh | sudo bash

On Windows, download the latest zip file from the official Rclone downloads page and extract it to a folder included in your PATH. For macOS users, Rclone can be installed via Homebrew:

brew install rclone

After installation, verify it by running rclone version in your terminal or command prompt. You should see the installed version information, confirming a successful installation.

Step 2: Configuring Your Cloud Storage Remote

Before you can sync files, you need to configure Rclone to access your cloud storage. Launch the configuration wizard by typing rclone config. You’ll be presented with a menu. Choose ‘n’ to create a new remote and give it a name (e.g., mygdrive). Next, select your desired cloud provider from the list, such as Google Drive (usually option 13).

Follow the prompts to authenticate your account. For some providers like Google Drive, Rclone will open a browser window for authentication. Copy and paste the verification code back into the terminal when prompted. Once completed, your remote will be available in Rclone’s configuration.

Step 3: Basic File Synchronization Commands

Once your remote is configured, you can begin syncing files. To copy files from your local machine to the cloud, use the following command:

rclone copy /path/to/local/folder mygdrive:/backup-folder

To synchronize both local and remote folders, ensuring they match, use:

rclone sync /path/to/local/folder mygdrive:/backup-folder

You can also sync files between two different cloud providers by specifying their remote names:

rclone sync mygdrive:/folder myonedrive:/folder

Always double-check the direction of synchronization to avoid unwanted data loss. The --dry-run flag can be added to preview changes without making actual modifications.

Step 4: Securing Your Transfers

Rclone transfers data using secure HTTPS connections by default. For extra security, especially when working with sensitive data, consider encrypting your remote using Rclone’s built-in crypt feature. During the configuration process, choose the crypt remote type and follow the prompts to set a password. This will ensure that files are encrypted before being uploaded to the cloud and decrypted only when accessed through Rclone.

Conclusion

Rclone is a versatile, efficient, and secure tool for managing, syncing, and backing up files across multiple cloud storage platforms. Its command-line interface makes it suitable for automation and scripting, while its robust security features protect your data. By following this guide, you can streamline your cloud workflows and ensure your important files are always safely synchronized.

How to Set Up and Use Rclone for Secure Cloud File Synchronization on Linux

Introduction

In today’s digital landscape, managing files efficiently across different cloud services is crucial for businesses and individuals alike. Rclone is a powerful open-source command-line program that enables seamless file synchronization between your local system and popular cloud storage providers like Google Drive, Dropbox, OneDrive, and more. In this tutorial, we will walk you through the installation and configuration of Rclone on Linux, and demonstrate how to securely synchronize your files with remote cloud storage.

Step 1: Installing Rclone on Linux

Rclone supports a wide range of Linux distributions. The easiest way to install the latest version is by using the official installation script. Open your terminal and run the following command:

curl https://rclone.org/install.sh | sudo bash

This command downloads and executes the installation script, ensuring you have the most up-to-date version installed. Alternatively, you can use your distribution’s package manager, but the repository version may be outdated.

Step 2: Configuring Your Cloud Storage Remote

Once installed, you need to configure Rclone to access your preferred cloud storage. Run the following command in your terminal:

rclone config

The interactive setup will guide you through creating a new remote. Select n for a new remote, choose a name (for example, gdrive), and pick your cloud provider from the list. For Google Drive, you will need to authenticate via your browser, allowing Rclone to access your files securely using OAuth 2.0.

You can repeat this process for multiple cloud services, making Rclone a unified tool for all your synchronization needs.

Step 3: Synchronizing Files Securely

To synchronize a local folder with your cloud storage, use the sync command. For example, the following command synchronizes the contents of ~/Documents with your Google Drive remote:

rclone sync ~/Documents gdrive:Backup/Documents

This command will mirror your local folder to the remote, uploading any new or updated files and deleting any that no longer exist locally. For a safer initial run, use the --dry-run flag to preview actions without making changes:

rclone sync ~/Documents gdrive:Backup/Documents --dry-run

Step 4: Encryption for Extra Security

If you want to keep your files private, Rclone offers built-in encryption. During rclone config, choose the crypt option to create an encrypted remote. You can chain this with your existing remote (e.g., crypt-gdrive layered over gdrive). All files uploaded via the crypt remote will be encrypted, keeping your data secure from prying eyes—even on the cloud provider’s side.

Step 5: Automating Sync with Cron

To automate synchronization, you can schedule regular sync jobs using cron. Open your crontab with crontab -e and add a line like:

0 2 * * * rclone sync ~/Documents gdrive:Backup/Documents --log-file ~/rclone.log

This example runs the sync at 2:00 AM daily and logs output to ~/rclone.log. Adjust the schedule to fit your workflow.

Conclusion

Rclone stands out as a versatile, secure, and efficient tool for managing and synchronizing files across multiple cloud storage platforms on Linux. By following the steps in this tutorial, you can easily set up, encrypt, and automate your file backups—ensuring your important data is always protected and accessible wherever you need it.

How to Set Up a Robust File Synchronization System Using Rclone

Introduction

File synchronization is a crucial process for individuals and businesses who need to keep files consistent across multiple devices or locations. One powerful tool for achieving efficient file synchronization is Rclone. This tutorial will guide you through setting up Rclone to synchronize files between a local machine and a remote cloud storage service.

Step 1: Installing Rclone

Firstly, you need to install Rclone on your system. Rclone is compatible with various operating systems including Linux, Windows, and macOS. Visit the official Rclone website (https://rclone.org) and download the appropriate version for your OS. On Linux, you can often install Rclone directly from the command line using:

sudo apt-get install rclone
For Windows and macOS, download the executable and follow the installation instructions provided on the site.

Step 2: Configuring Rclone

After installation, you need to configure Rclone with your cloud storage provider. Rclone supports a variety of cloud services such as Google Drive, Amazon S3, Dropbox, and many others. Run the following command to start the configuration process:

rclone config
This command launches an interactive setup process in your terminal. Choose 'n' for a new remote and provide a name for your configuration. Select your storage provider from the list and follow the prompts to enter your credentials, which may include API keys or access tokens. For detailed instructions for each provider, refer to the Rclone documentation.

Step 3: Running Your First Synchronization

With Rclone configured, you can start synchronizing your files. To sync files from your local directory to your cloud storage, use the following command:

rclone sync /path/to/local/folder remoteName:/path/to/remote/folder
Replace /path/to/local/folder with the path of your local directory and remoteName with the name of your remote configuration. This command ensures that the remote folder mirrors the local one. Be cautious, as this can overwrite files in the remote directory.

Advanced Features and Tips

Rclone offers various advanced features to enhance your file synchronization tasks. You can use the --dry-run option to preview what changes will be made before actually performing the sync. This is highly recommended to avoid unintended data loss. Additionally, Rclone can handle scheduled synchronizations using cron jobs (Linux/macOS) or Task Scheduler (Windows). This is useful for maintaining regular backups or ensuring continuous synchronization without manual intervention.

For users who need to manage large datasets or require high transfer speeds, considering the use of Rclone's multi-threaded transfers can significantly enhance performance. Use the --transfers flag to specify the number of file transfers to run in parallel:

rclone sync /path/to/local/folder remoteName:/path/to/remote/folder --transfers=4
This sets up four parallel file transfers, which can be adjusted based on your bandwidth and the capabilities of your storage provider.

Conclusion

Setting up Rclone for file synchronization offers a flexible and powerful solution to manage your data across various platforms and devices. By following this guide, you can ensure that your files are safely synchronized and accessible wherever you go. Always ensure to check the Rclone documentation for any specific configurations or additional features that might benefit your particular use case.

Popular Posts

Install Ollama and Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install Ollama + Open WebUI on Ubuntu 24.04 with NVIDIA GPU Acceleration (Step-by-Step)

Install a Local AI Chatbot on Ubuntu 24.04 with Ollama and Open WebUI (Step-by-Step)

Trending Now

Recovering from Btrfs Boot Failures Using GUI Tools on Fedora

By the end of this guide the reader will be able to identify a Btrfs‑based Fedora installation, boot from a live USB, list and restore snapshots using the graphical utilities btrfs‑assistant and snapper, and verify that the system returns to a functional state without resorting to the command line. Understanding the Btrfs Layout Used by Fedora Fedora Workstation and Fedora KDE install the root filesystem as a single Btrfs partition that contains two default sub‑volumes. One sub‑volume holds the traditional “/” hierarchy, while the second is dedicated to /var/lib/machines . The latter exists to keep container images out of snapshot operations; it remains empty on systems that do not run virtual machines. Because Btrfs stores data in sub‑volumes rather than separate partitions, a snapshot captures the state of an entire sub‑volume at a point in time. The installer (Anaconda) automatically registers these sub‑volumes with the snapper service. Snapper maintains a series of read‑only ...