diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-06-20 19:59:52 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-06-20 19:59:52 -0300 |
commit | 92bddda328f82484f98204dd60ae8112d11e4b87 (patch) | |
tree | 6380dd759a98be1bb87b5000797e0bbca2734d4b /share | |
parent | eb108899bb4f31e9cfdfcf431d44b111e9067068 (diff) | |
download | hydra-92bddda328f82484f98204dd60ae8112d11e4b87.tar.gz hydra-92bddda328f82484f98204dd60ae8112d11e4b87.tar.bz2 |
Adds sync-home
Diffstat (limited to 'share')
-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/ |