Created
November 29, 2010 12:01
-
-
Save wimleers/719879 to your computer and use it in GitHub Desktop.
Script that syncs a directory tree recursively to another server, to a single target ("flat") directory, using rsync.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
LOGFILE=/data/logs/dps-seedbox1-rsync/$(date "+%Y-%m").log | |
EXCLUDES_COMMON="--exclude lost+found --exclude .ssh --exclude .bash_history" | |
EXCLUDES_MORE="--exclude other --exclude BASE --exclude applications" | |
# Append a header first, so we know when this script was run. | |
date "+%n%n=====%nSyncing DriverPacks to seedbox1 at %Y-%m-%d %H:%M:%S" > $LOGFILE | |
# Sync the DriverPacks themselves to the seedbox' 'data' folder. However, we | |
# want all DriverPacks to end up in a single directory (they have unique | |
# filenames, so this is possible), so that the torrent client on the seedbox | |
# can associate the .torrent file with a DriverPack and will begin seeding. | |
# Hence we first find all subdirectories (hence `$DIR == */*`, which means | |
# that $DIR must contain a slash) that contain DriverPacks, and rsync from | |
# within each of those directories. | |
DIRS="$(rsync -a $EXCLUDES_COMMON $EXCLUDES_MORE --list-only --exclude="*.7z" /data/www/downloadsorigin.driverpacks.net/ | awk '{ print $5 }')" | |
for DIR in $DIRS | |
do | |
if [[ $DIR == */* ]]; | |
then | |
rsync -e "ssh -p 54312" -auvv $EXCLUDES_COMMON $EXCLUDES_MORE --no-relative /data/www/downloadsorigin.driverpacks.net/$DIR/ u4@gm1.ggshq.com:/mnt/u4/home/u4/data/ >> $LOGFILE | |
fi | |
done | |
# Sync the DriverPacks' .torrent files to the seedbox' 'watch' folder. | |
rsync -e "ssh -p 54312" -auvv $EXCLUDES_COMMON $EXCLUDES_MORE /data/www/svn_driverpacks.net/files/torrents/ u4@gm1.ggshq.com:/mnt/u4/home/u4/watch/ >> $LOGFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment