From 92bddda328f82484f98204dd60ae8112d11e4b87 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 20 Jun 2017 19:59:52 -0300 Subject: Adds sync-home --- share/hydractl/sync-home | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 share/hydractl/sync-home diff --git a/share/hydractl/sync-home b/share/hydractl/sync-home new file mode 100755 index 0000000..7be90ea --- /dev/null +++ b/share/hydractl/sync-home @@ -0,0 +1,36 @@ +#!/bin/bash +# +# sync-home +# + +# Parameters +BASENAME="$0" +TPC="$1" +DEST="/media/$1" +MEDIA="$DEST/var/cache/$TPC/media" +RSYNC="ionice -c 3 nice -n 19 rsync -av --delete --progress" + +# Syntax +if [ -z "$TPC" ]; then + echo "usage: $BASENAME " + exit 1 +elif [ ! -d "$DEST" ]; then + echo "folder $DEST does not exist." + exit 1 +fi + +# Sudo +if [ "$USER" != 'root' ]; then + export SUDO="sudo" +fi + +# Encrypted home +$SUDO mkdir -p $DEST/mnt/crypt/home + +# Encrypted mountpoints +for folder in /mnt/crypt/home/*; do + $SUDO mkdir -p $DEST/$folder +done + +# Sync files +$SUDO $RSYNC /home/ $DEST/home/ -- cgit v1.2.3