Rclone adalah command-line program yang memungkinkan Anda mengelola file di cloud storage. Dengan Rclone, Anda dapat sync, backup, dan transfer file antara VPS Linux dan berbagai cloud storage provider seperti Google Drive, Amazon S3, Dropbox, OneDrive, dan banyak lagi.
1. Instalasi dan Setup Awal Rclone
Rclone mendukung lebih dari 70 cloud storage provider dan dapat diinstall di semua distribusi Linux.
Instalasi Rclone
# Instal menggunakan official install script
curl https://rclone.org/install.sh | sudo bash
Verifikasi instalasi
rclone version
Update ke versi terbaru
sudo rclone selfupdate
Konfigurasi Rclone Interaktif
# Jalankan konfigurasi
rclone config
Pilih opsi untuk add new remote
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
Beri nama untuk remote (contoh: gdrive)
name> gdrive
Pilih storage type
Type of storage to configure.
Choose a number from below...
1 / 1Fichier
\ "fichier"
2 / Akamai NetStorage
\ "netstorage"
3 / Alias for an existing remote
\ "alias"
...
13 / Google Drive
\ "drive"
Storage> 13
Ikuti wizard untuk setup OAuth credentials
Rclone akan memberikan URL untuk authorization
Copy URL ke browser, authorize, dan paste code yang diberikan
Konfigurasi Manual dengan Config File
# File konfigurasi berada di ~/.config/rclone/rclone.conf
cat ~/.config/rclone/rclone.conf
Contoh config untuk berbagai provider:
[gdrive]
type = drive
client_id = your_client_id
client_secret = your_client_secret
token = {"access_token":"...","token_type":"Bearer","refresh_token":"...","expiry":"..."}
[s3backup]
type = s3
provider = AWS
env_auth = false
access_key_id = YOUR_ACCESS_KEY
secret_access_key = YOUR_SECRET_KEY
region = ap-southeast-1
location_constraint = ap-southeast-1
acl = private
[dropbox]
type = dropbox
token = {"access_token":"...","token_type":"bearer","expiry":"..."}
[onedrive]
type = onedrive
token = {"access_token":"..."}
drive_id = your_drive_id
drive_type = personal
2. Operasi Dasar Rclone
Setelah setup selesai, Anda dapat melakukan berbagai operasi file management.
List dan Navigasi Remote
# List semua remote yang terkonfigurasi
rclone listremotes
List file di remote (contoh: gdrive)
rclone ls gdrive:
rclone lsf gdrive:
rclone lsd gdrive: # List directory only
List dengan filter
rclone ls gdrive: --max-depth 2
rclone ls gdrive:/Documents
Cek ukuran direktori
rclone size gdrive:/Backups
rclone ncdu gdrive: # TUI file browser
Copy dan Transfer File
# Copy dari local ke remote
rclone copy /local/path gdrive:backup/
Copy dari remote ke local
rclone copy gdrive:backup/ /local/backup/
Copy dengan progress bar
rclone copy /var/www gdrive:website-backup --progress
Copy dengan filter
rclone copy /home/user/documents gdrive:docs --include "
.pdf"
rclone copy /home/user gdrive:user-data --exclude ".log"
rclone copy /data gdrive:data --include "
.jpg" --include ".png"
Copy dengan bandwidth limit
rclone copy /large/files gdrive: --bwlimit 500K
Move file (copy lalu hapus source)
rclone move /local/temp gdrive:temp/
Sinkronisasi Folder
# Sync (buat remote sama persis dengan local)
# PERHATIAN: File di remote yang tidak ada di local akan dihapus
rclone sync /local/path gdrive:remote/path
Sync dengan dry-run (preview perubahan)
rclone sync /local/path gdrive:remote/path --dry-run
Sync dua arah (bi-directional)
rclone bisync local:/path gdrive:path
Backup strategy (copy tanpa hapus)
rclone copy /var/www gdrive:www-backup/
3. Advanced Rclone Operations
Rclone memiliki banyak fitur advanced untuk kebutuhan enterprise.
Mount Cloud Storage sebagai Local Filesystem
# Mount Google Drive ke direktori lokal
rclone mount gdrive: ~/mnt/gdrive --vfs-cache-mode full --daemon
Access file seperti local filesystem
ls ~/mnt/gdrive
cp ~/mnt/gdrive/documents/file.pdf ~/local/
Unmount
fusermount -u ~/mnt/gdrive
atau
umount ~/mnt/gdrive
Encryption dengan Rclone Crypt
# Setup encrypted remote
rclone config
# Pilih crypt sebagai storage type
Struktur config
[gdrive-secure]
type = crypt
remote = gdrive:encrypted-folder
filename_encryption = standard
directory_name_encryption = true
password = your_encryption_password
password2 = salt_password
Copy file ke encrypted remote
rclone copy /sensitive/files gdrive-secure:
File akan terenkripsi otomatis sebelum upload
Backup Multiple Source
#!/bin/bash
# /home/user/scripts/rclone-backup.sh
Backup direktori penting
SOURCES=(
"/var/www"
"/etc/nginx"
"/home/user/documents"
"/opt/data"
)
REMOTE="gdrive:server-backup"
DATE=$(date +%Y-%m-%d)
for SOURCE in "${SOURCES[@]}"; do
BASENAME=$(basename "$SOURCE")
echo "Backing up $BASENAME..."
rclone copy "$SOURCE" "$REMOTE/$DATE/$BASENAME" --progress --transfers 4
done
Cleanup old backups (keep last 30 days)
rclone delete "$REMOTE" --min-age 30d
echo "Backup completed!"
Cron job untuk backup otomatis:
0 2 * * * /home/user/scripts/rclone-backup.sh >> /var/log/rclone-backup.log 2>&1
Bandwidth dan Transfer Control
# Limit bandwidth (500 KB/s)
rclone copy /data gdrive:backup --bwlimit 500K
Schedule bandwidth limit (business hours)
rclone copy /data gdrive:backup --bwlimit "08:00,500 17:00,off"
Parallel transfers (default 4, max bisa lebih)
rclone copy /data gdrive:backup --transfers 8 --checkers 16
Skip existing files (fast)
rclone copy /data gdrive:backup --ignore-existing
Update only if different size or modtime
rclone sync /data gdrive:backup --update
4. Rclone untuk Berbagai Cloud Provider
Google Drive
# Setup gdrive dengan OAuth
rclone config
# Pilih drive sebagai type
Cek quota
rclone about gdrive:
Share file
rclone link gdrive:/document.pdf
Search file
rclone ls gdrive: --include "
report"
Amazon S3
# Config S3
[s3prod]
type = s3
provider = AWS
access_key_id = YOUR_KEY
secret_access_key = YOUR_SECRET
region = ap-southeast-1
Operations
rclone ls s3prod:bucket-name/
rclone copy /local/data s3prod:mybucket/backup/
rclone sync /www s3prod:website-bucket/ --s3-acl public-read
Server-side encryption
rclone copy /secret s3prod:bucket --s3-server-side-encryption AES256
Backblaze B2
# Config B2
[b2backup]
type = b2
account = your_account_id
key = your_application_key
B2 has no directories, just files with path-like names
rclone ls b2backup:bucket-name
rclone copy /backup b2backup:my-bucket
SFTP/SSH
# Config SFTP
[myserver]
type = sftp
host = server.example.com
user = username
pass = password_encrypted
# Atau gunakan key
key_file = ~/.ssh/id_rsa
Gunakan untuk backup antar server
rclone sync /var/www myserver:/backup/www
5. Monitoring dan Maintenance
Logging dan Monitoring
# Verbose logging
rclone copy /data gdrive:backup -v
rclone copy /data gdrive:backup -vv # Very verbose
Log ke file
rclone copy /data gdrive:backup --log-file /var/log/rclone.log --log-level INFO
Stats real-time
rclone copy /data gdrive:backup --stats 10s
JSON output untuk parsing
rclone lsjson gdrive:backup
Integrity Check dan Verify
# Check integrity dengan MD5/SHA1
rclone check /local gdrive:backup
Compare dengan lebih detail
rclone check /local gdrive:backup --one-way --differ diff.txt
Verify setelah transfer besar
rclone check /large-dataset gdrive:backup --fast
Rclone sebagai REST API
# Serve remote via HTTP/FTP/WebDAV
rclone serve http gdrive: --addr :8080
rclone serve ftp gdrive: --addr :2121 --user admin --pass secret
rclone serve webdav gdrive: --addr :8080
Kesimpulan
Rclone adalah tools yang sangat powerful untuk mengelola cloud storage dari command line Linux. Dengan dukungan untuk 70+ provider, fitur encryption, bandwidth control, dan berbagai mode transfer, Rclone menjadi pilihan utama untuk backup dan sync di VPS.
Best Practices:
1. Selalu gunakan --dry-run sebelum sync
2. Setup encryption untuk sensitive data
3. Gunakan bandwidth limit untuk production server
4. Implementasikan rotation policy untuk backup
5. Monitor dengan logging
6. Test restore secara berkala
Keunggulan Rclone:
– Support hampir semua cloud provider
– Bandwidth control yang baik
– Encryption built-in
– Fast parallel transfers
– Checksum verification
– Incremental backup support
Alternatif Command:
– rclone dedupe – Remove duplicate files
– rclone mkdir – Create directories
– rclone rmdir – Remove empty directories
– rclone delete – Delete files
– rclone purge – Delete directory and all contents
– rclone cleanup – Cleanup trash/versions
– rclone cat – Concatenate files
Ditulis oleh
Hendra Wijaya