diff options
-rwxr-xr-x | share/hydractl/sync-home | 36 |
1 files changed, 36 insertions, 0 deletions
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 <tpc>" + 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/ |