blob: a0460e98ea0545c5517b95abb4b15dcb903e0b45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/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/
# Record log
$SUDO mkdir -p $DEST/var/log/hydra
echo "`date +%Y%m%d` $BASENAME with data from `cat /etc/hostname`" | $SUDO tee -a $DEST/var/log/hydra/sync-tpc > /dev/null
|