#!/bin/bash # # sync-tpc # # 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 --stats" # 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/ $SUDO $RSYNC /var/cache/virtualbox/ $DEST/var/cache/virtualbox/ $SUDO $RSYNC /var/cache/qemu/ $DEST/var/cache/qemu/ $SUDO $RSYNC /var/cache/vagrant/ $DEST/var/cache/vagrant/ $SUDO $RSYNC /var/cache/pbuilder/ $DEST/var/cache/pbuilder/ $SUDO $RSYNC /var/chroot/ $DEST/var/chroot/ $SUDO $RSYNC /var/lib/wicd/ $DEST/var/lib/wicd/ # Network config mkdir -p /etc/network/interfaces.d $SUDO cp -a /etc/network/interfaces $DEST/etc/network/interfaces $SUDO cp -a /etc/network/interfaces.d/* $DEST/etc/network/interfaces.d/ $SUDO cp -a /etc/udev/rules.d/70-persistent-net.rules $DEST/etc/udev/rules.d/70-persistent-net.rules # Wicd if [ -d "/etc/wicd" ]; then $SUDO mkdir -p $DEST/etc/wicd $SUDO cp -a /etc/wicd/manager-settings.conf $DEST/etc/wicd/manager-settings.conf $SUDO cp -a /etc/wicd/wireless-settings.conf $DEST/etc/wicd/wireless-settings.conf fi # Sync media remotes hydractl sync-media-remotes $MEDIA