Skip to content

Instantly share code, notes, and snippets.

@paucoma
Last active December 31, 2024 00:19
Show Gist options
  • Save paucoma/d842f9b1e25aae260a02b08e45b38ea6 to your computer and use it in GitHub Desktop.
Save paucoma/d842f9b1e25aae260a02b08e45b38ea6 to your computer and use it in GitHub Desktop.
Rclone Synology backup / sync with pCloud

Rclone Synology backup / sync with pCloud

// Background: I initially had a local server a synology DS215j
// Resources: 
//   - [ravem/synology-pcloud-and-rclone](https://github.com/ravem/synology-pcloud-and-rclone?tab=readme-ov-file)
//   - [Part 3. How To Backup Synology NAS to pCloud With Rclone](https://recoverit.wondershare.com/backup-files/synology-pcloud.html)
// Failed Alternatives : 
//   - I attempted to use the Synology package "Cloud Sync" with WebDaV as described [in this post](https://community.synology.com/enu/forum/1/post/186320) 
//      + The WebDAV Accesses {pCloud (US): https://webdav.pcloud.com ; pCloud (EU): https://ewebdav.pcloud.com}
//        * The username/password would not work and therefore I did not progress on this front.
  • Start a Command Prompt as Administrator:
Microsoft Windows [Version 10.0.22631.4602]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\System32>ssh [email protected]
The authenticity of host '192.168.1.125 (192.168.1.125)' can't be established.
ED25519 key fingerprint is SHA256:h+5TfdEFdsjhudfsGDsoijlkgdGJFGLG56456FDJjsw.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.125' (ED25519) to the list of known hosts.
[email protected]'s password:

Synology strongly advises you not to run commands as the root user, who has
the highest privileges on the system. Doing so may cause major damages
to the system. Please note that if you choose to proceed, all consequences are
at your own risk.
  • Gain access to root and install rclone:
user@synology:~$ sudo -i
Password:
root@synology:~# wget https://rclone.org/install.sh
--2024-12-30 17:27:35--  https://rclone.org/install.sh
Resolving rclone.org... 95.217.6.16, 2a01:4f9:c012:7154::1
Connecting to rclone.org|95.217.6.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4734 (4.6K) [application/x-shellscript]
Saving to: 'install.sh'

install.sh                    100%[=================================================>]   4.62K  --.-KB/s    in 0.001s

2024-12-30 17:27:36 (6.66 MB/s) - 'install.sh' saved [4734/4734]

root@synology:~# chmod +x install.sh
root@synology:~# ./install.sh

7-Zip [32] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.utf8,Utf16=on,HugeFiles=on,32 bits,2 CPUs LE)

Scanning the drive for archives:
1 file, 20907404 bytes (20 MiB)

Extracting archive: rclone-current-linux-arm-v7.zip
--
Path = rclone-current-linux-arm-v7.zip
Type = zip
Physical Size = 20907404

Everything is Ok

Folders: 1
Files: 5
Size:       63831811
Compressed: 20907404
mandb not found. The rclone man docs will not be installed.

rclone v1.68.2 has successfully installed.
Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.

root@comalogy:~# rclone config
2024/12/30 17:37:07 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
  • n) New remote
Enter name for new remote.
name> pcloud
  • name > pcloud
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
 1 / 1Fichier
   \ (fichier)
 2 / Akamai NetStorage
   \ (netstorage)
 3 / Alias for an existing remote
   \ (alias)
...
..
.
39 / Pcloud
   \ (pcloud)
.
..
...
57 / Zoho
   \ (zoho)
58 / premiumize.me
   \ (premiumizeme)
59 / seafile
   \ (seafile)
Storage> 39
  • 39 <--pCloud
Option client_id.
OAuth Client Id.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_id>
Option client_secret.
OAuth Client Secret.
Leave blank normally.
Enter a value. Press Enter to leave empty.
client_secret>
Edit advanced config?
y) Yes
n) No (default)
y/n> n
  • n
Use web browser to automatically authenticate rclone with remote?
 * Say Y if the machine running rclone has a web browser you can use
 * Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.

y) Yes (default)
n) No
y/n> n
  • n
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
        rclone authorize "pcloud"
Then paste the result.
Enter a value.
config_token> 
  • We need to leave this command prompt open while we search for the access token

=== Now via WSL or some system which has access to a browser as we will be using rclone to generate this access token

  • In my case I used WSL and installed rclone on there
Welcome to Ubuntu 22.04.3 LTS (GNU/Linux 5.15.167.4-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

This message is shown once a day. To disable it please create the
/home/paui/.hushlogin file.
user@laptop:~$ curl https://rclone.org/install.sh | sudo bash
[sudo] password for user:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4734  100  4734    0     0  15219      0 --:--:-- --:--:-- --:--:-- 15270

Archive:  rclone-current-linux-amd64.zip
   creating: rclone-v1.68.2-linux-amd64/
  inflating: rclone-v1.68.2-linux-amd64/README.html
  inflating: rclone-v1.68.2-linux-amd64/rclone.1
  inflating: rclone-v1.68.2-linux-amd64/rclone
  inflating: rclone-v1.68.2-linux-amd64/README.txt
  inflating: rclone-v1.68.2-linux-amd64/git-log.txt
Purging old database entries in /usr/share/man...
Processing manual pages under /usr/share/man...
Purging old database entries in /usr/share/man/es...
Processing manual pages under /usr/share/man/es...
Purging old database entries in /usr/share/man/da...
Processing manual pages under /usr/share/man/da...
Purging old database entries in /usr/share/man/de...
Processing manual pages under /usr/share/man/de...
Purging old database entries in /usr/share/man/ko...
Processing manual pages under /usr/share/man/ko...
Purging old database entries in /usr/share/man/ru...
Processing manual pages under /usr/share/man/ru...
Purging old database entries in /usr/share/man/pt...
Processing manual pages under /usr/share/man/pt...
Purging old database entries in /usr/share/man/sv...
Processing manual pages under /usr/share/man/sv...
Purging old database entries in /usr/share/man/it...
Processing manual pages under /usr/share/man/it...
Purging old database entries in /usr/share/man/fr...
Processing manual pages under /usr/share/man/fr...
Purging old database entries in /usr/share/man/uk...
Processing manual pages under /usr/share/man/uk...
Purging old database entries in /usr/share/man/cs...
Processing manual pages under /usr/share/man/cs...
Purging old database entries in /usr/share/man/ro...
Processing manual pages under /usr/share/man/ro...
Purging old database entries in /usr/share/man/id...
Processing manual pages under /usr/share/man/id...
Purging old database entries in /usr/share/man/fi...
Processing manual pages under /usr/share/man/fi...
Purging old database entries in /usr/share/man/zh_TW...
Processing manual pages under /usr/share/man/zh_TW...
Purging old database entries in /usr/share/man/sl...
Processing manual pages under /usr/share/man/sl...
Purging old database entries in /usr/share/man/ja...
Processing manual pages under /usr/share/man/ja...
Purging old database entries in /usr/share/man/tr...
Processing manual pages under /usr/share/man/tr...
Purging old database entries in /usr/share/man/pl...
Processing manual pages under /usr/share/man/pl...
Purging old database entries in /usr/share/man/nl...
Processing manual pages under /usr/share/man/nl...
Purging old database entries in /usr/share/man/zh_CN...
Processing manual pages under /usr/share/man/zh_CN...
Purging old database entries in /usr/share/man/sr...
Processing manual pages under /usr/share/man/sr...
Purging old database entries in /usr/share/man/hu...
Processing manual pages under /usr/share/man/hu...
Purging old database entries in /usr/share/man/pt_BR...
Processing manual pages under /usr/share/man/pt_BR...
Processing manual pages under /usr/local/man...
mandb: can't update index cache /var/cache/man/oldlocal/1095: No such file or directory
Updating index cache for path `/usr/local/man/man1'. Wait...done.
Checking for stray cats under /usr/local/man...
Checking for stray cats under /var/cache/man/oldlocal...
1 man subdirectory contained newer manual pages.
1 manual page was added.
0 stray cats were added.
2 old database entries were purged.

rclone v1.68.2 has successfully installed.
Now run "rclone config" for setup. Check https://rclone.org/docs/ for more details.
  • As specified on our server rclone configuration:
user@laptop:~$ rclone authorize "pcloud"
2024/12/30 17:42:22 NOTICE: Config file "/home/user/.config/rclone/rclone.conf" not found - using defaults
2024/12/30 17:42:22 NOTICE: If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=dOJFD34hjdfda092q3T
2024/12/30 17:42:22 NOTICE: Log in and authorize rclone for access
2024/12/30 17:42:22 NOTICE: Waiting for code...
  • Now we open a browser goto the provided link and login to grant access and select Allow

Connect rclone.org to your account

Success!


All done. Please go back to rclone

2024/12/30 17:44:15 NOTICE: Got code
Paste the following into your remote machine --->
{"access_token":"3lskjdfDSAFSJDFKL8738943kXjsdfjksxY0ihdjhsdf3988DFFQ","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
<---End paste
user@laptop:~$

=== Now back to synology ssh access

Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
        rclone authorize "pcloud"
Then paste the result.
Enter a value.
config_token> 
{"access_token":"3lskjdfDSAFSJDFKL8738943kXjsdfjksxY0ihdjhsdf3988DFFQ","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
  • we paste the access_token: {"access_token":"3lskjdfDSAFSJDFKL8738943kXjsdfjksxY0ihdjhsdf3988DFFQ","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
Configuration complete.
Options:
- type: pcloud
- token: {"access_token":"3lskjdfDSAFSJDFKL8738943kXjsdfjksxY0ihdjhsdf3988DFFQ","token_type":"bearer","expiry":"0001-01-01T00:00:00Z"}
Keep this "pcloud" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
  • y
Current remotes:

Name                 Type
====                 ====
pcloud               pcloud

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q
root@synology:~#
  • to verify that you have access use rclone to browse remote base directories:
root@synology:~# rclone lsd pcloud:
          -1 2021-01-01 10:15:51        -1 .Trash-1000
          -1 2021-01-01 11:11:31        -1 Automatic Upload
          -1 2021-11-21 11:31:11        -1 Backups
          -1 2021-01-21 11:01:11        -1 My Music
          -1 2021-12-10 21:41:15        -1 My Pictures
          -1 2021-11-21 10:11:51        -1 My Videos
          -1 2021-01-01 11:41:17        -1 Screenshots
root@synology:~#

Configuration Complete : you can logout


Usage of rclone with pcloud

Examples:

1.start an ssh session to snyology server 2. sudo rclone copy /var/services/photo/ pcloud:/mirrors/P/ --exclude "@eaDir/**" --exclude ".Trash-1000/**" -v --dry-run

@paucoma
Copy link
Author

paucoma commented Dec 30, 2024

Screenshotpcloudrcloneconnect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment