# ☁️ Seamless Cloud Backup & Restore using Rclone: Pcloud ➡️ AWS S3 Automation

## **Aim 🎯**

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**. 🌐✅

### **Introduction 📖**

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 ✅**.

## 📁 **Agenda**

* 🛠️ Prerequisites Setup
    
* 🖥️ EC2 Instance Configuration
    
* 👤 IAM User & S3 Bucket Creation
    
* 📦 Rclone Installation & Remote Configuration
    
* 💻 Backup & Restore Script Development
    
* ⏱️ Cron Automation Setup
    
* 🧪 Testing & Verification
    
* 🏁 Conclusion
    

## 🛠️ **Prerequisites**

* ✅ AWS Account with EC2 access
    
* ✅ PCloud account(any other cloud) with data to backup
    
* ✅ Basic Linux command knowledge
    
* ✅ SSH access to Ubuntu server
    

## 🖥️ **Step 1: EC2 Instance Setup**

## Launch Ubuntu EC2 Instance

```powershell
# 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
```

## Connect to Instance

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755227497547/b96706b4-ea88-4f51-8d39-866ef60a1474.png align="center")

## 👤 **Step 2: IAM User & S3 Bucket Creation**

## 🔏Create IAM User

1. Go to AWS IAM Console
    
2. Create new user: `rclone-backup-user`
    
3. Attach policy: `AmazonS3FullAccess`
    
4. Generate Access Keys (save securely)
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755227576393/14da3778-4450-4e73-90c9-9130d8478ea2.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755227593603/dd62e385-655e-4792-8ca8-ab2fe1d100f7.png align="center")
    

## 🪣Create S3 Bucket

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755227947603/6937f948-d1a5-4580-844a-e78e7ce7c2f4.png align="center")

## 📦 **Step 3: Rclone Installation & Configuration**

## Install Rclone

```powershell
sudo apt update
sudo apt install -y rclone
rclone version
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755228131488/dd07ff6b-55ca-448b-aa4f-9884ddcda37a.png align="center")

## Configure PCloud Remote

```powershell
# 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:

```powershell
rclone authorize "pcloud"
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755228382430/768c126b-6a44-4a6d-b6f6-18d06e497a44.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755228252264/39d8c97e-afc1-4165-8c4d-15ef5572ad08.png align="center")

## Configure AWS S3 Remote

```powershell
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]
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755240085958/dd6913b2-4cdc-4805-84d7-351205fb877a.png align="center")

## Verify Remotes

```powershell
rclone listremotes
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755228301821/9f7629fc-52d2-4aee-b88f-cd2974f4be1d.png align="center")

## 💻 **Step 4: Create Backup & Restore Script**

## Create Script Directory

### Create <mark>backup_restore.sh</mark>

```powershell
vim backup_restore.sh
```

## Script Content

```powershell
#!/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.
        

## Make Script Executable

```powershell
chmod +x backup_restore.sh
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755230905535/18913b15-d347-45a3-ab0f-d401fe1072ad.png align="center")

---

## 🔄 **Step 5: Manual Testing**

## Test Backup

```powershell
./backup_restore.sh
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755230934271/55cdd965-1b8a-4401-add7-3d22a58b76f4.png align="center")

## ⏱️ **Step 6: Automate with Cron**

## Open Crontab

```powershell
crontab -e
```

## Add Cron Job (Every 1 minute)

```powershell
*/1 * * * * /home/ubuntu/backup_restore.sh >> /var/log/backup_restore_cron.log 2>&1
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755231421527/546090b0-30ed-48a9-9bd3-e1b4c8392e2b.png align="center")

### **A. List Files in** `/home/ubuntu/` Directory

```powershell
ls -l /home/ubuntu/
```

Displays a detailed list of all files and directories inside `/home/ubuntu/`.

### **B. Create a Folder Named** `myfiles`

```powershell
mkdir -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.

### **C. Create** `test1.txt` with Sample Content

```powershell
echo "Test file" > /home/ubuntu/myfiles/test1.txt
```

Creates a file named `test1.txt` inside `myfiles` and writes `Test file` into it.

### **D. Create** `test2.txt` with Sample Content

```powershell
echo "Another file" > /home/ubuntu/myfiles/test2.txt
```

Creates a file named `test2.txt` inside `myfiles` and writes `Another file` into it.

### **E. Copy Files to AWS S3 (Dry Run)**

```powershell
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.

### **F. Sync Files from pCloud to AWS S3**

```powershell
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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755231592797/e3485b11-084a-4706-b2f0-28ea63d255b1.png align="center")

---

## 🧪 **Step 7: Testing & Verification**

## Case Study 1: Existing Files

* ✅ All existing PCloud files synced to S3
    
* ✅ Directory structure maintained
    
* ✅ File integrity preserved
    

## Case Study 2: New File Addition

1. Add new file to PCloud
    
2. Wait 1 minute
    
3. Check S3 bucket → File automatically appears
    
4. Verify in logs
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755231806680/4310d27b-adf7-4bb3-b054-6604ef3d7398.png align="center")

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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755231837915/a58dd079-7a3f-4a52-b63e-3ef72c8613bf.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755231847653/3abae256-6ebf-412d-a140-74e57fe9626e.png align="center")

### ⚠️ Challenges & ✅ Success in Automating Secure Backup from pCloud to AWS S3

**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.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1755232281644/d1be1082-3d5d-4031-b260-f2aaea547af0.png align="center")

**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**.
    

## **conclusion:**

* ✅ 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**.
    

## **👨‍💻 About the Author**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1751797710818/123a7231-3dca-4273-ad68-7bd026f69b95.png?auto=compress,format&format=webp&auto=compress,format&format=webp&auto=compress,format&format=webp&auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

This series isn't just about using AWS; it's about **mastering the core services that power modern cloud infrastructure**.

---

### 📬 Let's Stay Connected

* 📧 **Email**: [**gujjarapurv181@gmail.com**](mailto:gujjarapurv181@gmail.com)
    
* 🐙 **GitHub**: [**github.com/ApurvGujjar07**](http://github.com/ApurvGujjar07)
    
* 💼 **LinkedIn**: [**linkedin.com/in/apurv-gujja**](http://linkedin.com/in/apurv-gujja)**r**
