diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2016-10-02 15:31:42 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2016-10-02 15:31:42 -0300 |
commit | fdb07b542860089eb208ec5967826a2225899d10 (patch) | |
tree | 1684d5eee1520e8416c6775416f459afed04c02b /share/hydractl/sync-media-export | |
parent | d13a337e8bc54ace1ea98ff5faae01d525d9dd21 (diff) | |
download | hydra-fdb07b542860089eb208ec5967826a2225899d10.tar.gz hydra-fdb07b542860089eb208ec5967826a2225899d10.tar.bz2 |
Adds media and backup scripts originally from puppet-backup
Diffstat (limited to 'share/hydractl/sync-media-export')
-rwxr-xr-x | share/hydractl/sync-media-export | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/share/hydractl/sync-media-export b/share/hydractl/sync-media-export new file mode 100755 index 0000000..7b47639 --- /dev/null +++ b/share/hydractl/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 |