PengyOS / Docs / Recipes / rclone
rclone
rclone copies and syncs files to and from almost any storage: S3 and compatibles, Backblaze B2, Google Drive, OneDrive, Dropbox, SFTP, WebDAV and more. It's a single program in your home directory.
ServerDesktop
Install
mkdir -p ~/.local/bin && cd /tmp
curl -fsSLO https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip -q -o rclone-current-linux-amd64.zip
install -m 755 rclone-*-linux-amd64/rclone ~/.local/bin/
rclone version
rclone's own install.sh writes into /usr/bin, which is read-only on
PengyOS. Use the steps above. rclone selfupdate upgrades in place later.
Connect a remote
rclone config # interactive: n (new), a name, the provider, credentials
Providers that sign in through a browser (Google Drive, OneDrive, Dropbox) open one on the
Desktop. On a Server, answer n to "use web browser". rclone then prints an
rclone authorize … command to run on a computer that has a browser. Paste its
result back. The configuration lives in ~/.config/rclone/rclone.conf.
rclone listremotes
rclone lsd b2: # top-level folders/buckets
rclone ls b2:my-bucket/photos | head
Copy and sync
rclone copy ~/Documents b2:my-bucket/documents -P # add/update, never delete
rclone sync ~/Documents b2:my-bucket/documents -P --dry-run # make the remote match; check first…
rclone sync ~/Documents b2:my-bucket/documents -P # …then for real
rclone check ~/Documents b2:my-bucket/documents # compare
sync deletes files on the destination that aren't in the source.
Run it with --dry-run first, and point it the right way round.
Back up every night
Use a systemd user timer. This one copies your documents and your
photos offsite. Create ~/.config/systemd/user/offsite.service:
[Unit]
Description=Offsite copy with rclone
[Service]
Type=oneshot
ExecStart=%h/.local/bin/rclone sync %h/Documents b2:my-bucket/documents --log-level INFO
ExecStart=%h/.local/bin/rclone copy %h/Pictures b2:my-bucket/pictures --log-level INFO
and ~/.config/systemd/user/offsite.timer:
[Unit]
Description=Nightly offsite copy
[Timer]
OnCalendar=*-*-* 03:30:00
Persistent=true
[Install]
WantedBy=timers.target
sudo loginctl enable-linger "$USER" # run even when you're not logged in
systemctl --user daemon-reload
systemctl --user enable --now offsite.timer
systemctl --user start offsite.service # try it now
journalctl --user -u offsite.service # what it did
Mount a remote
A remote can appear as a folder:
mkdir -p ~/Cloud
rclone mount gdrive: ~/Cloud --vfs-cache-mode writes --daemon
ls ~/Cloud
fusermount3 -u ~/Cloud # unmount
--vfs-cache-mode writes lets ordinary apps save into the mount. Mounting works on
the Server too from 26.10.0. Releases before that have no FUSE there, so use
copy/sync instead. rclone serve shares a remote over
WebDAV, SFTP or HTTP on either edition.