diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-05-31 15:38:59 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-05-31 15:38:59 -0300 |
commit | 3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583 (patch) | |
tree | 96ebd2b0d63bdcb68e02732f0cfe05f6d0b9f969 /files/sync-media-export | |
parent | 21723c5e2a0426eef1e87d65fd356505f0046648 (diff) | |
download | puppet-backup-3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583.tar.gz puppet-backup-3e2b07f09b0cde2fbc2a7a7c2cfcf88452945583.tar.bz2 |
Adding sync-media-expor and sync-media-init
Diffstat (limited to 'files/sync-media-export')
-rw-r--r-- | files/sync-media-export | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/files/sync-media-export b/files/sync-media-export new file mode 100644 index 0000000..7b47639 --- /dev/null +++ b/files/sync-media-export @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copy git-annex repositories to remote server. +# + +# Parameters +BASENAME="`basename $0`" +DESTINATION="$1" +DOMAIN="`facter DOMAIN`" +MEDIA="/var/cache/media" + +# Syntax check +if [ -z "$DESTINATION" ]; then + echo "usage: $BASENAME <DESTINATION>" + exit 1 +fi + +# Process each repository +for file in `ls $MEDIA`; do + if [ -d "$MEDIA/$file/.git/annex" ]; then + ( + echo Processing "$MEDIA/$file..." + + cd $MEDIA + + if ssh $DESTINATION if [ -d \"/var/cache/media/$file\" ] \; then echo exists\; fi | grep -q exists; then + echo "Remote $file already exists, skipping..." + continue; + fi + + git clone $file $file.git && \ + rsync -avz $file.git/ $DESTINATION:/var/cache/media/$file/ && \ + rm -rf $file.git + echo "" + ) + fi +done |