βοΈ Seamless Cloud Backup & Restore using Rclone: Pcloud β‘οΈ AWS S3 Automation

Search for a command to run...

No comments yet. Be the first to comment.
Learn AWS from basics to advanced with daily hands-on tasks and real-world projects. Master core services like EC2, S3, IAM, Lambda, and more all explained in a practical, job-ready DevOps format.
π Introduction Data loss can be costly whether due to accidental deletion, hardware failure, or system crashes . In this blog, we will set up an automated backup and restore system using AWS S3, AWS CLI, and cron jobs, starting completely from scrat...
Master GitLab CI/CD Variables, Secrets Management, Artifacts & Best Practices π Introduction In the previous article, we learned how GitLab Runners execute CI/CD pipelines and how to configure Self-H

Learn GitLab Runners, Hosted vs Self-Hosted Runners, Runner Registration, Tags, Pipeline Editor & Parallel Jobs π Introduction In the previous article, we created our first GitLab CI/CD pipeline and

Learn Continuous Integration, Continuous Delivery, Pipelines, Stages, Jobs & .gitlab-ci.yml π Introduction In the previous articles, we explored GitLab fundamentals, repository management, and collab

Learn Docker Scout, Multi-Stage Builds, Docker Hardened Images (DHI), SBOM, Docker Model Runner, Ask Gordon AI, and production-ready container security through practical, real-world examples. Introduc

Import Repositories, Mirroring & Repository Management Best Practices π Introduction In the previous articles, we learned the fundamentals of GitLab, created projects, and configured secure authentic

The aim of this task is to securely backup and restore data from another cloud (Pcloud) to AWS S3. πΎπ
To achieve this, I performed the entire task using Rclone, created an automated Bash script, and scheduled Cron jobs to ensure continuous, safe, and hassle-free data synchronization. πβ
Data is the most valuable asset π»πΎ, and keeping it safe and accessible is crucial. In this task, I used Rclone with sync to securely backup and restore data from Pcloud to AWS S3 βοΈβ‘οΈβοΈ. With a Bash script π₯οΈ and Cron jobs β°, the process is fully automated, secure, and hassle-free β .
π οΈ Prerequisites Setup
π₯οΈ EC2 Instance Configuration
π€ IAM User & S3 Bucket Creation
π¦ Rclone Installation & Remote Configuration
π» Backup & Restore Script Development
β±οΈ Cron Automation Setup
π§ͺ Testing & Verification
π Conclusion
β AWS Account with EC2 access
β PCloud account(any other cloud) with data to backup
β Basic Linux command knowledge
β SSH access to Ubuntu server
# Instance Type: t3.micro (Free tier eligible)
# AMI: Ubuntu Server 22.04 LTS
# Security Group: Allow SSH (Port 22)
# Key Pair: Create or use existing

Go to AWS IAM Console
Create new user: rclone-backup-user
Attach policy: AmazonS3FullAccess
Generate Access Keys (save securely)



sudo apt update
sudo apt install -y rclone
rclone version

# Choose: n (New remote)
# Name: pcloud
# Storage: pcloud
# Follow OAuth authentication process
# Add your pcloud token
Use the command below to generate a token for pCloud and download it locally:
rclone authorize "pcloud"


rclone config
# Choose: n (New remote)
# Name: s3
# Storage: s3
# Provider: AWS
# Access Key ID: [Your IAM Access Key]
# Secret Access Key: [Your IAM Secret Key]
# Region: us-east-1
# Endpoint: [Leave blank]
# Location constraint: [Leave blank]

rclone listremotes

vim backup_restore.sh
#!/bin/bash
# Remotes
PCLOUD_REMOTE="pcloud:"
S3_REMOTE="aws_s3:mybucket1-apurv"
# Log files
BACKUP_LOG="/var/log/pcloud_to_s3_backup.log"
RESTORE_LOG="/var/log/s3_to_pcloud_restore.log"
# ----------------------------
# 1. Backup: pCloud β S3
# ----------------------------
echo "Starting backup from pCloud to S3..."
rclone sync $PCLOUD_REMOTE $S3_REMOTE --log-level=ERROR >> $BACKUP_LOG 2>&1
echo "Backup completed. Log: $BACKUP_LOG"
# ----------------------------
# 2. Restore: S3 β pCloud
# ----------------------------
echo "Starting restore from S3 to pCloud..."
rclone sync $S3_REMOTE $PCLOUD_REMOTE --log-level=ERROR >> $RESTORE_LOG 2>&1
echo "Restore completed. Log: $RESTORE_LOG"
Remotes:
* $PCLOUD_REMOTE β pCloud account remote.
* $S3_REMOTE β AWS S3 bucket remote.
* Log files:
* $BACKUP_LOG β stores backup errors/output.
* $RESTORE_LOG β stores restore errors/output.
*Backup (pCloud β S3) β rclone sync copies data from pCloud to S3 and logs errors.
*Restore (S3 β pCloud) β rclone sync restores data back from S3 to pCloud with logging.
* --log-level=ERROR >> $RESTORE_LOG 2>&1 β logs errors only.
* Echo messages: Show start and completion of backup/restore in terminal.
chmod +x backup_restore.sh

./backup_restore.sh

crontab -e
*/1 * * * * /home/ubuntu/backup_restore.sh >> /var/log/backup_restore_cron.log 2>&1

/home/ubuntu/ Directoryls -l /home/ubuntu/
Displays a detailed list of all files and directories inside /home/ubuntu/.
myfilesmkdir -p /home/ubuntu/myfiles
Creates a folder called myfiles inside /home/ubuntu/. The -p option ensures the command wonβt give an error if the folder already exists.
test1.txt with Sample Contentecho "Test file" > /home/ubuntu/myfiles/test1.txt
Creates a file named test1.txt inside myfiles and writes Test file into it.
test2.txt with Sample Contentecho "Another file" > /home/ubuntu/myfiles/test2.txt
Creates a file named test2.txt inside myfiles and writes Another file into it.
rclone copy /home/ubuntu/myfiles aws_s3:mybucket1-apurv --dry-run --log-level=ERROR
Uses rclone to copy all files from /home/ubuntu/myfiles to the AWS S3 bucket named mybucket1-apurv.
The --dry-run option simulates the copy process without actually transferring the files.
rclone sync pcloud: aws_s3:mybucket1-apurv --log-level=ERROR
Uses rclone to sync files from the pCloud storage to the AWS S3 bucket mybucket1-apurv.--log-level=ERROR shows only error messages during execution.

β All existing PCloud files synced to S3
β Directory structure maintained
β File integrity preserved
Add new file to PCloud
Wait 1 minute
Check S3 bucket β File automatically appears
Verify in logs

I uploaded ad.jpg to pCloud, remove text file , the cron job automatically synced it to the S3 bucket within a minute. Screenshot of the automatic sync is attached below.


Task Overview & Challenges:
β³ Faced major difficulties over 2 days while setting up backup and restore between pCloud and S3.
πΎ Backup worked, but restore had issues initially.
Steps Taken & Solutions:
π€ Uploaded data to pCloud, but cron job was not picking up latest changes immediately.
β Initially, latest files were missing in backup due to timing issues.
π Switched to using rclone sync, which automatically updates S3 whenever any change happens in pCloud.
β±οΈ Cron job now syncs every minute, ensuring real-time backup.
β
Tested with rclone copy to verify that the remote connection and permissions were correct.

Results:
π οΈ After solving all errors, backup is now working perfectly.
π All data is synced securely and automatically from pCloud β AWS S3.
πΈ Screenshots attached show successful backup and automation in action.
Conclusion for Challenges :
π€ Automated backup with cron + rclone ensures highly secure, real-time sync.
β¨ Reduces manual effort and guarantees up-to-date cloud storage.
β Learned how to automate secure cloud backup using pCloud, AWS S3, cron, and Rclone.
π‘ Gained hands-on experience in troubleshooting errors, syncing data, and ensuring real-time updates.
π Successfully set up a fully automated, secure, and reliable backup system.

This series isn't just about using AWS; it's about mastering the core services that power modern cloud infrastructure.
π§ Email: gujjarapurv181@gmail.com
π GitHub: github.com/ApurvGujjar07
πΌ LinkedIn: linkedin.com/in/apurv-gujjar