This document describes a setup to synchronize secret data to cloud storage in a way that the cloud provider does not have access to the original files. All files in a local folder (C:\Non-Cloud
) are read, encrypted on the fly, and stored to a folder that is synchronized by a cloud storage client application such as OneDrive (C:\Users\<USER>\OneDrive\Personal Data\OneCrypt
). Restoring and decrypting files works analogously.
The cloud storage client application will undertake the actual synchronization, but will never see the decrypted files. Encryption keys are stored on the local system - but please take care that the folder they reside in is not inadvertently stored in the cloud!
With a little effort, this setup can also be modified to synchronize to the cloud directly without using a client application.
- save all passwords and salts in a password safe such as KeePass!
- when setting up rclone, you usually do not have to edit the advanced configuration
- do not quote the remote path (in the configuration)
- save some time by setting the target folder (
OneCrypt
in my case) on OneCloud to "Always keep on this device" - when you rename files in a Git repository and only change the case (
file.TXT
→File.txt
):- try to avoid this, the case-insensitivity of Windows / OneDrive is a pain
- do not rename files using File Explorer, Visual Studio Code etc., otherwise you'll get strange Git results
- rename with
git mv
instead
- clone this repository to a folder on your OneDrive
- download rclone
- extract the ZIP archive and move its contents into the folder
.\rclone
- reading rclone's excellent manual can't hurt :-)
- add an alias to the unencrypted source folder (technically, this is not necessary, but helps to prevent backing up the wrong location):
$ .\rclone\rclone.exe config
No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> NonCloud
Storage> alias
remote> C:\Non-Cloud
- if you also want to sync your
Downloads
folder, add a second alias (change<USER>
to your user name):
$ .\rclone\rclone.exe config
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> n
name> Downloads
Storage> alias
remote> C:\Users\<USER>\Downloads
- add encrypted remote folder, in this case OneDrive (change
<USER>
to your user name):
$ .\rclone\rclone.exe config
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> n
name> OneCrypt
Storage> crypt
nounc>
remote> C:\Users\<USER>\OneDrive\Personal Data\OneCrypt
filename_encryption> off
directory_name_encryption> true
Password or pass phrase for encryption.
y) Yes, type in my own password
g) Generate random password
y/g> g
Bits> 128
Password or pass phrase for salt.
y) Yes, type in my own password
g) Generate random password
y/g/n> g
Bits> 128
- create a (possibly empty) file
exclude_files.txt
in the.\sync
folder - see the file./sync/exclude_files.txt.orig
for some recommended exclusions
Note: the scripts in this section will also synchronize your Downloads
folder. So you have to either set it up as described above or change the scripts.
Run the Windows batch script sync/1-backup_to_cloud.bat.
Run the Windows batch script sync/2-restore_from_cloud.bat.
Run the Windows batch script sync/3-check_differences.bat.
.\rclone\rclone.exe selfupdate