Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2001db8/d7db0ee35c088cc8c8ce6e1ed22f5d1c to your computer and use it in GitHub Desktop.
Save 2001db8/d7db0ee35c088cc8c8ce6e1ed22f5d1c to your computer and use it in GitHub Desktop.
Setting up a encrypted drive on Amazon Cloud Drive w/ EncFS and acd_cli

Environment

export ACD_LOCAL=$HOME/.cache/Amazon-Cloud-Drive

# To use this file later
export ENCFS6_CONFIG=$ACD_LOCAL/encfs6.xml

Setup

mkdir -p \
$ACD_LOCAL/local.encrypted \
$ACD_LOCAL/local.plaintext \
$ACD_LOCAL/cloud.encrypted \
$ACD_LOCAL/cloud.plaintext

# On first run, you'll need to setup EncFS. Just use the defaults.
# Since we don't upload the key, it's OK to use an empty passphrase
# Useful options, case insentive file names, 4K blocks, path-independent filenames
encfs \
$ACD_LOCAL/local.encrypted \
$ACD_LOCAL/local.plaintext

acd_cli mount --modules="subdir,subdir=/Encrypted" \
$ACD_LOCAL/cloud.encrypted

# Backup key & configuration for safe-keeping
# TODO: this shouldn't be in ~/.cache/!
ln \
$ACD_LOCAL/local.encrypted/.encfs6.xml \
$ACD_LOCAL/encfs6.xml


encfs \
$ACD_LOCAL/cloud.encrypted \
$ACD_LOCAL/cloud.plaintext

unionfs-fuse -o cow \
$ACD_LOCAL/local.plaintext=RW:\
$ACD_LOCAL/cloud.plaintext=RO \
$HOME/Cloud

Sync

# Periodically run:
# (will prevent uploading of key and config to cloud)
acd_cli sync
acd_cli upload -x 4 --exclude-ending encfs6.xml \
$ACD_LOCAL/local.encrypted/* \
/Encrypted/

Garbage collection

# Remove files older than 7 days and empty directories
find $ACD_LOCAL/local.encrypted/ -type f -mtime +7 -print0 | xargs -0 -n256 rm
find $ACD_LOCAL/local.encrypted/ -type d -empty -delete
# Or immediately remove any local files
find $ACD_LOCAL/local.encrypted/ -type f -print0 | xargs -0 -n256 rm

Unmount

# Unmount everything
fusermount -u $HOME/Cloud/
fusermount -u $ACD_LOCAL/cloud.plaintext
fusermount -u $ACD_LOCAL/cloud.encrypted
fusermount -u $ACD_LOCAL/local.plaintext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment