Skip to content

Instantly share code, notes, and snippets.

@kernel-sanders
Last active March 21, 2019 16:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kernel-sanders/61be0a92dce20116abc5 to your computer and use it in GitHub Desktop.
Save kernel-sanders/61be0a92dce20116abc5 to your computer and use it in GitHub Desktop.
ACD UnionFS
mkdir -p \
$HOME/.cache/Amazon-Cloud-Drive/local.encrypted \
$HOME/.cache/Amazon-Cloud-Drive/local.plaintext \
$HOME/.cache/Amazon-Cloud-Drive/cloud.encrypted \
$HOME/.cache/Amazon-Cloud-Drive/cloud.plaintext
ENCFS6_CONFIG=$HOME/.cache/encfs6.xml encfs -o allow_other $HOME/.cache/Amazon-Cloud-Drive/local.encrypted $HOME/.cache/Amazon-Cloud-Drive/local.plaintext
acd_cli mount --modules="subdir,subdir=/Encrypted" $HOME/.cache/Amazon-Cloud-Drive/cloud.encrypted
ENCFS6_CONFIG=$HOME/.cache/encfs6.xml encfs -o allow_other $HOME/.cache/Amazon-Cloud-Drive/cloud.encrypted $HOME/.cache/Amazon-Cloud-Drive/cloud.plaintext
unionfs-fuse -o cow $HOME/.cache/Amazon-Cloud-Drive/local.plaintext=RW:$HOME/.cache/Amazon-Cloud-Drive/cloud.plaintext=RO:/RAID=RO $HOME/Cloud
acd_cli sync
acd_cli upload -x 8 --exclude-ending encfs6.xml $HOME/.cache/Amazon-Cloud-Drive/local.encrypted/* /Encrypted/
sudo fusermount -u $HOME/Cloud/
sudo fusermount -u $HOME/.cache/Amazon-Cloud-Drive/cloud.plaintext
sudo fusermount -u $HOME/.cache/Amazon-Cloud-Drive/cloud.encrypted
sudo fusermount -u $HOME/.cache/Amazon-Cloud-Drive/local.plaintext
#===================
# as root
mkdir -p \
/mnt/acd \
/mnt/.RAID \
/mnt/acd-RAID
acd_cli mount --modules="subdir,subdir=/RAID" /mnt/acd/
# first run only
encfs --reverse /RAID /mnt/.RAID
mv /RAID/.encfs6.xml $HOME/.cache/encfs6.xml
fusermount -u /mnt/.RAID
mkdir $HOME/backup-scripts
echo "PASSWORD_HERE" > $HOME/backup-scripts/enc-passwd
chmod 500 $HOME/backup-scripts/enc-passwd
# End first run only section
ENCFS6_CONFIG=$HOME/.cache/encfs6.xml encfs --reverse /RAID /mnt/.RAID
cat $HOME/backup-scripts/enc-passwd | ENCFS6_CONFIG=$HOME/.cache/encfs6.xml encfs -S --reverse /RAID /mnt/.RAID
cat $HOME/backup-scripts/enc-passwd | ENCFS6_CONFIG=$HOME/.cache/encfs6.xml encfs -S /mnt/acd/ /mnt/acd-RAID
# now run the backup script
#========================
#!/bin/bash
# This script will upload all files in $local_location to Amazon Cloud Drive using acd_cli to $remote_location
# It will skip already uploaded files by comparing hashes
# Original https://github.com/dcplaya/acd_cli-BackupScripts/blob/master/Movies_Upload.sh from David Carpenter
# Updated for python3.4
#Set to true if you want to run acd_cli with verbose
verbose=true
#Set local location of files to upload. Everything in this folder will be uploaded but no the folder itself
local_location=/mnt/.RAID/
#Set remote location on ACD
remote_location=/RAID
#Set location of where to store log file as well as the name
log_location=/root/backup-scripts/RAID-upload.log
# Start of actual code!
################################################################################################################################################
#Sync to make sure we have the most up to date file structure
acd_sync
if [ "$verbose" == true ]
then
echo "Verbose enabled!"
acd_cli -v sync # Syncs with ACD before uploading to make sure we have the most up to date info
acd_cli -v upload -xp /mnt/.RAID/dz4djkzUsxPYv-Jq5C3UDkGK -x 8 "$local_location"* "$remote_location" 2> >(tee "$log_location" >&2) # Starts uploading with the locations set at the top of this script
else
acd_cli -v sync # Syncs with ACD before uploading to make sure we have the most up to date info
acd_cli -v upload -xp /mnt/.RAID/dz4djkzUsxPYv-Jq5C3UDkGK -x 8 "$local_location"* "$remote_location" # Starts uploading with the locations set at the top of this script
fi
exit 0
@preexo
Copy link

preexo commented Jul 20, 2016

Cool script, very useful and a nice example of how to properly mount acd into an existing filesystem!
But I wonder, where does the folder /RAID come from? I don't have this folder on my system and don't see why I would need that for the rest to work.

Also this line acd_cli upload -x 8 --exclude-ending encfs6.xml $HOME/.cache/Amazon-Cloud-Drive/local.encrypted/* /Encrypted/ is giving me [ERROR] [acd_cli] - Path "/home/pi/.cache/Amazon-Cloud-Drive/local.encrypted/*" does not exist..

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