diff options
Diffstat (limited to 'ansible/roles/holywood2/files/rsync-to-nalanda')
-rwxr-xr-x | ansible/roles/holywood2/files/rsync-to-nalanda | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/ansible/roles/holywood2/files/rsync-to-nalanda b/ansible/roles/holywood2/files/rsync-to-nalanda new file mode 100755 index 0000000..20f3cfe --- /dev/null +++ b/ansible/roles/holywood2/files/rsync-to-nalanda @@ -0,0 +1,33 @@ +#!/bin/bash + +set -euo pipefail + +from="$1" +server="$2" +dir="$3" +shift 3 + +new="$dir/new" +dated="$dir/$(date -Id)" + +echo "Syncing $from to staging area on $server" +rsync -rlthHS --partial --stats --exclude=lost+found \ + "$from/." "$server:$new/." "$@" +echo + +if ssh "$server" test -e "$dated"; then + echo "$dated exists, removing it" + ssh "$server" find "$dated" -type d -exec chmod +rw '{}' + + ssh "$server" rm -rf "$dated" +fi + +echo "Making a hardlink copy to $dated" +ssh "$server" mkdir "$dated" +ssh "$server" cp -al "$new/." "$dated/." + +echo +ssh "$server" df -h . +echo + +echo "All good" +echo |