Encrypted pCloud Backup with rclone

Guide: a nightly, client-side encrypted backup from the Mac to pCloud with rclone and launchd, with a 90-day archive and tested restores.

A hot-air balloon carrying a locked safe floats among night clouds, connected by a cable to a laptop on a windowsill below.

My guide, published on 2026-10-06, to a backup that runs every night by itself, stores the data encrypted in the cloud and keeps changed or deleted files for weeks. rclone copies, pCloud stores, rclone crypt encrypts on the Mac, and launchd starts the run at 02:00.

Status

Working and tested with a test folder ~/TestBackup (54 files, about 1 MB). With this offsite copy, my 3-2-1 setup is complete. A notification on errors is not built yet.

Result

  • Every night at 02:00 the chosen folders go to pCloud. File names and contents are encrypted on the client; pCloud only sees scrambled names.
  • aktuell/ always holds the latest state of the source.
  • Changed or deleted files move to archiv/<date_time>/ and stay there for 90 days.
  • Nothing is ever deleted on the Mac. On an error the script stops with an exit code other than 0.
  • A second, manual script backs up without encryption into a separate folder Backup-Klartext, for files that should open in the pCloud web interface.

How it works

rclone has no versioning of its own: rclone sync mirrors the source, so whatever is overwritten or deleted would be gone at the target. The archive comes from --backup-dir, which moves those files into a folder named after the run's timestamp, and from a few lines in the script that remove archive folders older than 90 days. It keeps one state per run, not a complete history of every file.

The script ~/.local/bin/pcloud-backup.sh:

  • runs rclone sync <source> pcloudcrypt:aktuell/<name> --backup-dir pcloudcrypt:archiv/<stamp>/<name> for every folder in SOURCES;
  • excludes caches, temporary files, node_modules, the trash and virtual machine images;
  • takes a lock directory so that two runs never overlap;
  • stops if a source is missing or empty, because otherwise sync would move the whole backup into the archive;
  • uses set -euo pipefail, offers --dry-run, and logs to ~/Library/Logs/pcloud-backup.log.

Setup steps: install rclone with Homebrew (no sudo; the missing mount on macOS does not matter for backups), create the remote pcloud (an EU account needs the hostname eapi.pcloud.com), then the crypt remote pcloudcrypt on pcloud:Backup with a generated password and salt of 1024 bits each. rclone shows the generated password only once.

Tests

  • Restore of a single file: identical SHA-256 checksums.
  • rclone check of the whole folder: 0 differences. With crypt, rclone reports "No common hash found" and compares size and time instead.
  • Missing source: the script stops with "Quelle fehlt" and exit code 1.
  • Archive: in a throwaway folder, a changed and a deleted file both appeared in the archive folder of that run.
  • Cleanup: of two artificial archive folders, only the one older than 90 days was removed.

Pitfalls

  • --min-age 90d deletes too early. It checks the file's modification time, and --backup-dir keeps it. A two-year-old file deleted today would be removed from the archive on the next run. The script deletes whole archive folders by the timestamp in their name instead.
  • Empty arrays in the Bash 3.2 of macOS. With set -u, "${DRY[@]}" on an empty array fails with "unbound variable"; ${DRY[@]+"${DRY[@]}"} works.
  • The exit trap swallowed the error code. The trap has to save and return the status: trap 'rc=$?; rmdir "$LOCK_DIR" 2>/dev/null; exit $rc' EXIT.
  • macOS privacy protection (TCC). A launchd job cannot read ~/Desktop, ~/Documents or ~/Downloads and sees them as empty. I moved the source out of these folders rather than granting /bin/bash Full Disk Access.
  • Never share the rclone configuration output. It contains the OAuth token in plain text. After it happened, I revoked the access in pCloud first and then reconnected with rclone config reconnect pcloud:.

What has to be kept elsewhere

The crypt password and salt (in the password manager) and a copy of ~/.config/rclone/rclone.conf. The file holds the pCloud token and the crypt passwords only obscured, not encrypted (rclone reveal makes them readable), so it is treated like a password. Without password and salt the encrypted backup cannot be restored. On a new Mac the order matters: restore first, then switch the schedule back on, or sync would mirror the half-empty state and push the rest into the archive.

The 3-2-1 setup

The original on the Mac or NAS, a backup on the NAS, a backup on an external disk made from the NAS, and pCloud as the copy outside the house. The archive also protects against accidental deletion and ransomware for 90 days. I test a restore once a quarter.

More on this

Topic
  • Backup Copies of data that can be restored after deletion, damage or loss, and the ways to make, keep and test them.
Uses
  • launchd The service manager of macOS. A launch agent in ~/Library/LaunchAgents starts a script for the user on a schedule, like cron.
  • pCloud Cloud storage service with accounts in an EU and a US region. I keep the offsite copy of my backup there, encrypted by rclone.
  • rclone Command-line program that copies and syncs files to and from many cloud storage services, with optional client-side encryption (crypt).

Show in the graph view →