Skip to content

Instantly share code, notes, and snippets.

@unsalted
Last active November 29, 2022 05:45
Show Gist options
  • Save unsalted/12bc24cff3876ca5ca9759d5a04ad472 to your computer and use it in GitHub Desktop.
Save unsalted/12bc24cff3876ca5ca9759d5a04ad472 to your computer and use it in GitHub Desktop.
Linux cryptomator rsync and mount scripts

Cryptomator Sync and Mount Scripts

  • Used on Kubuntu 16.04
  • Used with Cryptomator
  • Cryptomator must be decrypted prior to using any of the scripts.

Dependencies

  • rsync
  • davfs2
  • Cryptomator

Todo

  • watch script with sync
#!/bin/bash
WDAV="WEB_DAV_URL"
# sudo required
sudo mount -t davfs $WDAV "/home/USERNAME/DEST" -o uid=$USERNAME
#!/bin/bash
#Make sure to set variables!
USR="USERNAME"
ENV=$(hostname | cut -d"." -f1 |tr "[:upper:]" "[:lower:]")
SRC_DIR="Documents"
SRC="/home/${USR}/${SRC_DIR}"
BASE=$(basename $SRC)
DIR="PATH" # ~/Crypt/Backup => Crypt/Backup
DEST="/home/${USR}/${DIR}"
WDAV="URI" # http://localhost:42427/dlskfjsldkjf/Crypt/
EXC="--exclude .git/ --exclude node_modules/ --exclude bower_components/ --exclude .DS_Store/ --exclude .DS_Store" #Excludes
if [ -d $DEST ]
then
echo "Clean Mount"
sudo umount -t davfs $DEST
fi
echo "Mount - sudo required, press return for username and password"
sudo mount -t davfs $WDAV $DEST -o uid=$USR
echo "Syncing"
/usr/bin/rsync -rtv --ignore-existing --del --delete-excluded $EXC "${SRC}/" "${DEST}/${ENV}-${BASE}/"
echo "Sync Finished"
#!/bin/bash
SRC="/home/USERNAME/DEST"
#sudo required
sudo umount -t davfs /home/USERNAME/Crypt
@TheRoarkster
Copy link

Just wanted to let you know this script was really helpful to automating my backup to a Cryptomator virtual drive. Thank you for posting it.

@joshlester
Copy link

I second @TheRoarkster, very helpful. Thank you.

@unsalted
Copy link
Author

👍 glad it helped.

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