Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.
/ old-cloud Public archive

Synchronizing files on different computers using emacs + remote directory + symmetric encryption

Notifications You must be signed in to change notification settings

chalaev/old-cloud

Repository files navigation

Table of Contents

  1. Description
  2. Prerequisites
  3. Quick start
    1. Initial setup
    2. Uploading and downloading files
  4. Commands
  5. Limitations
  6. License

Intended for linux users who have emacs always open.

Description

Synchronizing important files on two or more computers using

  1. emacs + GNU make,
  2. some sort of a cloud that can be mounted to a directory, for example, an a. ssh-server, or b. some public cloud service (e.g., Russian Yandex Disk or Swiss pCloud) that can be mounted in linux using standard open-source utilities, and
  3. symmetric encryption a. using ImageMagick for JPEG and PNG images or b. using gpg for other (presumably text) files.

Encrypted files saved in the cloud have random names to minimize the amount of information cloud owners can extract by monitoring our cloud directory.

Prerequisites

We need

  1. emacs, GNU make, ImageMagick, gpg, sed, and gawk; in Debian these can be installed as follows:
    aptitude install emacs make imagemagick gpg sed gawk
  2. lisp-goodies: start.el (used by Makefile), and shalaev.el
  3. (for testing only) el-debug.el

Quick start

I am running emacs in daemon mode (in text console) using the following line in ~/.login:

emacs --daemon

Once emacs was started in the daemon mode, I can use emacsclient -c to open a new (gui) emacs window.

Initial setup

  1. mkdir ~/.emacs.d/local-packages/.

  2. Place shalaev.el and cloud.el to ~/.emacs.d/local-packages/

  3. Load start.el in your ~/.emacs

  4. Evaluate cloud.el in emacs at start by placing the following lines

    (require 'cloud)
    (cloud-start)
    

    into your ~/.emacs file. In emacs, update some of the files , then M-x cloud-sync. During the very first (cloud-start) run, configuration file ~/.emacs.d/cloud/`hostname`/config will be created.

  5. Mount remote directory. The mounting point may be arbitrary (specified as cloud-directory in ~/.emacs.d/cloud/`hostname`/config), the default one is /mnt/cloud/.

Uploading and downloading files

There are several log files; the least informative one is ~/.emacs.d/cloud/`hostname`/log described in files.org.

  1. Edit a text file in emacs. Unless it is blacklisted it will automatically be clouded when you save it. (Blacklisted files can be manually clouded using M-x cloud-add.)
  2. Run M-x cloud-sync to upload the file and tail -f ~/.emacs.d/cloud/`hostname`/log to see the log.
  3. Now you can move to another host (e.g. from your office desktop to your laptop).
  4. Using some secure way, copy ~/.emacs.d/cloud/`hostname`/config to another host; launch cloud.el there and check the log files. Ensure that updated on your previous host files were downloaded to your current host.
  5. Let me know if something is unclear or does not work.

Every time we M-x cloud-sync, local files get synchronized with the cloud. (The same happens when we start/quit emacs.) For this purpose I have a line in my crontab:
43 9-21 * * * emacsclient -e "(cloud-sync)" &> /dev/null

Commands

Except for M-x cloud-sync, commands are barely used:

  • M-x cloud-add adds one or several files to the list of "clouded" files. This means that M-x cloud-sync command will upload these "clouded" files to the remote server if they are updated. Supposed to be used in dired buffer for several (marked) files, or (when no files are marked) for a single file. Files edited in emacs are clouded automatically, but there are exceptions – see sample configuration file and the source code. Works both on files and directories.
  • M-x cloud-forget is the opposite of M-x cloud-add. It is also called automatically when files are removed in dired buffer. Currently works on files only, not on directories.
  • M-x cloud-sync syncronizes local files with the cloud. Could be regularly called with a crontab line, e.g.,
    43 9-21 * * * emacsclient -e "(cloud-sync)" &> /dev/null

Limitations

  1. I use GNU make together with its --jobs option to enjoy (unsupported in emacs) multi-threading, and thus I have to suffer from the make restriction: only nicely named files will work.
    In particular, no spaces in file names are allowed. (This limitation can probably be circumvented by creating soft links to badly named files.)
  2. Encrypting images is just a toy feature for now; it has to be better developed to become really useful. After encrypting an image file and then decrypting it back, we get the same, but not identical picture (file size is changed).

License

This code is released under MIT license.

About

Synchronizing files on different computers using emacs + remote directory + symmetric encryption

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published