While transferring files to a secondary VPS using rsync is a solid backup strategy, managing a second entire server solely for storage can be expensive and time-consuming. Modern disaster recovery often relies on Cloud Object Storage—such as Amazon S3, Backblaze B2, or Cloudflare R2. These platforms offer massive scalability, 99.999% data durability, and significantly lower costs per gigabyte.

To seamlessly connect your Linux server to these cloud providers, you can use Rclone. Often described as "the Swiss Army knife of cloud storage," Rclone is a powerful command-line utility that manages file synchronizations to over 70 distinct cloud storage products.

Installing Rclone

Unlike standard packages that might be outdated in default repositories, the Rclone developers provide a secure, automated installation script that guarantees you receive the latest stable version directly on your VPS.

  • Connect to your server via SSH as a user with sudo privileges.

  • Execute the official installation script by running: sudo -v ; curl [https://rclone.org/install.sh](https://rclone.org/install.sh) | sudo bash.

  • Wait for the script to download the correct binary for your system architecture and install it into your system's executable path.

  • Verify the installation by running rclone --version.

Configuring the Cloud Remote

Before Rclone can upload anything, you must configure a "remote"—a connection profile containing your specific cloud provider's API credentials and bucket details.

  • Launch the interactive configuration wizard by running rclone config.

  • Type n to create a New remote and give it a memorable name, such as s3-backup.

  • Scroll through the list of supported storage providers and enter the number corresponding to your specific provider (for example, Amazon S3 or a generic S3-compliant provider).

  • Follow the prompts to paste in your Access Key ID and Secret Access Key, which you must generate from your cloud provider's dashboard.

  • Leave advanced configuration options blank unless your provider strictly requires a specific geographic region endpoint.

Enabling Client-Side Encryption

Storing backups in the cloud introduces a new privacy risk: if your cloud provider's account is compromised, your raw data is exposed. Rclone solves this by offering a transparent client-side encryption layer. This ensures your files are encrypted locally on your server before they are ever transmitted over the network.

  • Run rclone config again and create another new remote, naming it secure-backup.

  • When asked for the storage type, select Crypt (usually option 14 or similar, depending on the version).

  • When prompted for the underlying remote to encrypt, point it to the bucket you created in the previous step (e.g., s3-backup:my-vps-bucket-name).

  • Choose to encrypt both the file contents and the file names to maximize privacy.

  • Generate or provide a highly secure password and an optional salt. You must save this exact password in a secure offline password manager; if you lose it, your cloud backups will be permanently unreadable.

Automating the Cloud Sync

With your encrypted remote configured, you can now push your application directories or database dumps directly to the cloud automatically.

  • Open your user's scheduled tasks by running crontab -e.

  • Add a new line to execute the upload every night at 4:00 AM:

    0 4 * * * rclone sync /backups/ secure-backup: / --transfers 4 --checkers 8 > /dev/null 2>&1

  • The sync command ensures that the cloud bucket becomes an exact mirror of your local /backups/ directory. If a file is deleted locally (like an old database dump), Rclone will automatically remove it from the cloud bucket to save you storage costs.

 
Esta resposta lhe foi útil? 0 Usuários acharam útil (0 Votos)