Archive: System v4 - Estado al 2024-12-24
This commit is contained in:
222
v4-archive/locker/R2_SYNC_CLIENT.md
Normal file
222
v4-archive/locker/R2_SYNC_CLIENT.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# Sincronización R2 con rclone
|
||||
|
||||
Configuración de sincronización bidireccional entre carpeta local y Cloudflare R2.
|
||||
|
||||
## Requisitos
|
||||
|
||||
- rclone instalado
|
||||
- Credenciales R2 (Access Key + Secret)
|
||||
- macOS con launchd o Linux con systemd
|
||||
|
||||
## Instalación rclone
|
||||
|
||||
### macOS
|
||||
```bash
|
||||
brew install rclone
|
||||
```
|
||||
|
||||
### Linux
|
||||
```bash
|
||||
curl https://rclone.org/install.sh | sudo bash
|
||||
```
|
||||
|
||||
## Configuración
|
||||
|
||||
### 1. Crear archivo de configuración
|
||||
|
||||
```bash
|
||||
mkdir -p ~/.config/rclone
|
||||
```
|
||||
|
||||
### 2. Configurar remote R2
|
||||
|
||||
**~/.config/rclone/rclone.conf:**
|
||||
```ini
|
||||
[r2-architect]
|
||||
type = s3
|
||||
provider = Cloudflare
|
||||
access_key_id = {ACCESS_KEY}
|
||||
secret_access_key = {SECRET_KEY}
|
||||
endpoint = https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com
|
||||
acl = private
|
||||
```
|
||||
|
||||
### 3. Verificar conexión
|
||||
|
||||
```bash
|
||||
# Listar contenido del bucket
|
||||
rclone lsf r2-architect:architect/
|
||||
|
||||
# Con verbose para debug
|
||||
rclone ls r2-architect:architect/ -vv
|
||||
```
|
||||
|
||||
## Sincronización
|
||||
|
||||
### Sync unidireccional (R2 → Local)
|
||||
|
||||
```bash
|
||||
rclone sync r2-architect:architect/ "/path/to/local/folder/" --progress
|
||||
```
|
||||
|
||||
### Sync unidireccional (Local → R2)
|
||||
|
||||
```bash
|
||||
rclone sync "/path/to/local/folder/" r2-architect:architect/ --progress
|
||||
```
|
||||
|
||||
### Bisync bidireccional
|
||||
|
||||
```bash
|
||||
# Primera vez: inicializar con --resync
|
||||
rclone bisync "/path/to/local/folder/" r2-architect:architect/ --resync --verbose
|
||||
|
||||
# Ejecuciones posteriores
|
||||
rclone bisync "/path/to/local/folder/" r2-architect:architect/ --verbose
|
||||
```
|
||||
|
||||
## Automatización
|
||||
|
||||
### macOS (launchd)
|
||||
|
||||
**~/Library/LaunchAgents/com.rclone.r2-sync.plist:**
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.rclone.r2-sync</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/opt/homebrew/bin/rclone</string>
|
||||
<string>bisync</string>
|
||||
<string>/Users/{user}/R2 Folder/</string>
|
||||
<string>r2-architect:architect/</string>
|
||||
<string>--verbose</string>
|
||||
</array>
|
||||
<key>StartInterval</key>
|
||||
<integer>300</integer>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/Users/{user}/Library/Logs/rclone-r2-sync.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/Users/{user}/Library/Logs/rclone-r2-sync.log</string>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
**Comandos launchd:**
|
||||
```bash
|
||||
# Cargar servicio
|
||||
launchctl load ~/Library/LaunchAgents/com.rclone.r2-sync.plist
|
||||
|
||||
# Ver estado
|
||||
launchctl list | grep r2-sync
|
||||
|
||||
# Detener
|
||||
launchctl unload ~/Library/LaunchAgents/com.rclone.r2-sync.plist
|
||||
```
|
||||
|
||||
### Linux (systemd)
|
||||
|
||||
**~/.config/systemd/user/rclone-r2-sync.service:**
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Rclone R2 Bisync
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/rclone bisync /home/{user}/R2/ r2-architect:architect/ --verbose
|
||||
```
|
||||
|
||||
**~/.config/systemd/user/rclone-r2-sync.timer:**
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Run rclone R2 sync every 5 minutes
|
||||
|
||||
[Timer]
|
||||
OnBootSec=1min
|
||||
OnUnitActiveSec=5min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
```
|
||||
|
||||
**Comandos systemd:**
|
||||
```bash
|
||||
# Habilitar
|
||||
systemctl --user enable rclone-r2-sync.timer
|
||||
systemctl --user start rclone-r2-sync.timer
|
||||
|
||||
# Ver estado
|
||||
systemctl --user status rclone-r2-sync.timer
|
||||
|
||||
# Ejecutar manualmente
|
||||
systemctl --user start rclone-r2-sync.service
|
||||
```
|
||||
|
||||
## Buckets R2 Disponibles
|
||||
|
||||
| Bucket | Uso | Credenciales |
|
||||
|--------|-----|--------------|
|
||||
| architect | Backups, configs, APKs | Token: architect-sync |
|
||||
| hst | Imágenes HST | Token: locker-full-access |
|
||||
| deck | Archivos personales | Token: locker-full-access |
|
||||
| corp | Documentos empresariales | Token: locker-full-access |
|
||||
| locker | General/temporal | Token: locker-full-access |
|
||||
|
||||
## Tokens R2
|
||||
|
||||
### locker-full-access (todos los buckets)
|
||||
```
|
||||
Endpoint: https://7dedae6030f5554d99d37e98a5232996.r2.cloudflarestorage.com
|
||||
Access Key: ecddc771824c3cb3417d9451780db3d2
|
||||
Secret Key: [ver creds_locker en PostgreSQL]
|
||||
```
|
||||
|
||||
### architect-sync (solo bucket architect)
|
||||
```
|
||||
Access Key: 55125dca442b0f3517d194a5bc0502b8
|
||||
Secret Key: [ver creds_locker.r2_architect_token en PostgreSQL]
|
||||
```
|
||||
|
||||
## Comandos útiles
|
||||
|
||||
```bash
|
||||
# Ver logs en tiempo real
|
||||
tail -f ~/Library/Logs/rclone-r2-sync.log
|
||||
|
||||
# Sync manual inmediato
|
||||
rclone bisync "/path/to/folder/" r2-architect:architect/ --verbose
|
||||
|
||||
# Ver diferencias sin sincronizar
|
||||
rclone check "/path/to/folder/" r2-architect:architect/
|
||||
|
||||
# Listar con tamaños
|
||||
rclone ls r2-architect:architect/
|
||||
|
||||
# Subir archivo específico
|
||||
rclone copy archivo.txt r2-architect:architect/path/
|
||||
|
||||
# Descargar archivo
|
||||
rclone copy r2-architect:architect/path/archivo.txt ./
|
||||
```
|
||||
|
||||
## Configuración cliente local
|
||||
|
||||
Ejemplo configurado en Mac (pablotzr):
|
||||
|
||||
| Componente | Valor |
|
||||
|------------|-------|
|
||||
| Carpeta local | /Users/pablotzr/Architect R2/ |
|
||||
| Bucket R2 | architect |
|
||||
| Sync | Bidireccional (bisync) |
|
||||
| Frecuencia | Cada 5 minutos |
|
||||
| Servicio | com.rclone.r2-architect-sync |
|
||||
| Logs | ~/Library/Logs/rclone-r2-sync.log |
|
||||
|
||||
---
|
||||
Creado: 2024-12-24
|
||||
Reference in New Issue
Block a user