Skip to content

Simple and secure rclone + GPG cloud backup script for Linux. Compress → Encrypt → Upload to any cloud (OneDrive, Google Drive, S3, etc). Easy to use, beginner-friendly, cron-ready, with retention and logs.

Notifications You must be signed in to change notification settings

popek1990/rclone-gpg-cloud-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rclone-gpg-cloud-backup

Version 1.0

A simple and secure backup script for Linux: compress → encrypt → upload to the cloud.
Uses rclone + GPG to create encrypted archives and send them to your cloud storage (OneDrive, Google Drive, S3, etc).


🚀 Features

  • Compress multiple folders/files into one archive
  • Encrypt the archive with GPG (public key)
  • Upload encrypted archive to any rclone remote
  • Automatic cleanup of old backups (local + remote)
  • Beginner-friendly and cron-ready
  • Colorful logs and optional ASCII banner

🖥️ Requirements

  • Linux with bash
  • GPG (recipient public key required)
  • rclone configured
  • tar, zstd or pigz/gzip

➡️ Full list is in requiraments


📝 Quick-Start Guide

1. Clone this repo to your server

git clone https://github.com/popek1990/rclone-gpg-cloud-backup.git
cd rclone-gpg-cloud-backup

2. Make files executable

  1. Make files executable Before running the script, make sure it has execute permissions:
sudo chmod +x rclone-gpg-cloud-backup.sh requiraments

Install required packages

Install all system dependencies automatically from the included list:

sudo apt update
grep -v '^#' requirements.txt | xargs -r sudo apt install -y
  • rclone last version / official installer:

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

4. Edit starter config

cd rclone-gpg-cloud-backup && \
sudo nano rclone.conf

After open this file in your text editor (for example nano) set:

  • BACKUP_ITEMS — which folders/files to back up
  • GPG_RECIPIENT_FPR — your GPG public key fingerprint # `gpg --list-keys
  • REMOTE_NAME — rclone remote name (e.g. onedrive, gdrive, s3)
  • REMOTE_DIR — base folder on cloud storage

3. Configure rclone (if not yet done)

Make sure your rclone remote is working:

rclone config

You can test access to your remote with (example for OneDrive):

rclone lsd onedrive:

4. Test run (no upload)

Run a full compression and encryption test without sending files to the cloud:

./rclone-gpg-cloud-backup.sh --dry-run

If everything works correctly, you will see messages similar to:

✅ Dependencies OK.
✅ Encrypted: /path/to/archive.tar.zst.gpg
🚧 Dry-run: upload skipped

5. Run full backup

To create and upload an encrypted backup:

./rclone-gpg-cloud-backup.sh

This will:

  1. Compress all items listed in BACKUP_ITEMS
  2. Encrypt the archive with your GPG key
  3. Upload the .gpg file to your rclone cloud remote
  4. Clean up old backups automatically (based on retention)

6. Add to CRON (optional)

To automate daily backups at 02:00, add this line to your crontab:

0 2 * * * /path/to/rclone-gpg-cloud-backup.sh >> /var/log/rclone-gpg-cloud-backup.log 2>&1

Check your cron logs to confirm it’s running correctly.


🖼️ How It Works

  1. Collects all paths from BACKUP_ITEMS
  2. Creates a compressed archive (.tar.zst or .tar.gz)
  3. Encrypts it with your GPG public key.gpg
  4. Uploads to:
    REMOTE_NAME:REMOTE_DIR/LABEL/HOST_TAG/YYYY-MM-DD/
    
  5. Deletes old archives (based on retention settings)

⚙️ Configuration Example

Edit your local config file ./.rclone.conf with values similar to:

BACKUP_ITEMS=( "/etc" "$HOME/projects" )
BACKUP_ROOT="$HOME/cloud-backup"
LABEL="myserver"
HOST_TAG="$(hostname -s)"
COMPRESSION="zstd"

GPG_RECIPIENT_FPR="9KASPA3681F2041TAODB3ACNEPTUNE54124D1A"
GPG_IMPORT_KEY_FILE=""

REMOTE_NAME="onedrive"
REMOTE_DIR="Backups"

LOCAL_RETENTION_DAYS="30"
REMOTE_RETENTION_DAYS="45"

🧠 Tips

  • Quick health check (deps + config + GPG + rclone):
    ./rclone-gpg-cloud-backup.sh --check
  • Skip cleanup (keep all backups):
    ./rclone-gpg-cloud-backup.sh --no-retain
  • Logs are stored under:
    $BACKUP_ROOT/YYYY-MM-DD/<label>_cloud_backup_<timestamp>.log
    

🔐 Security Notes

  • Always verify your GPG key fingerprint before placing it in the config file.
  • Import a public key manually if needed:
    gpg --import /path/to/public_key.asc
  • List available keys:
    gpg --list-keys

💬 Support & Contributions

If you find this project useful — star ⭐ it on GitHub and share it.
Pull requests with small improvements (e.g., better logging or new cloud examples) are welcome.


📜 Changelog

Version 1.0

  • Initial release: compression, encryption, upload + retention
  • Separate config file (./.rclone.conf) and cron support
  • Beginner-friendly and portable

About

Simple and secure rclone + GPG cloud backup script for Linux. Compress → Encrypt → Upload to any cloud (OneDrive, Google Drive, S3, etc). Easy to use, beginner-friendly, cron-ready, with retention and logs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages