Skip to content

Instantly share code, notes, and snippets.

@pulecp
Last active August 29, 2015 14:15
Show Gist options
  • Save pulecp/b177866cbfd88eef0d81 to your computer and use it in GitHub Desktop.
Save pulecp/b177866cbfd88eef0d81 to your computer and use it in GitHub Desktop.
#!/bin/bash
# I suppose that you have current data in /var/lib/carbon/whisper
# and data which you want to sync in /var/lib/carbon/var/lib/carbon/whisper
wget https://raw.githubusercontent.com/graphite-project/whisper/master/bin/whisper-fill.py
src_dir=`find /var/lib/carbon/var/lib/carbon/whisper -type f`
for i in $src_dir
do
src_file="$i"
dst_file=`echo $i|sed 's#^/var/lib/carbon##'`
echo "src_file: $src_file"
echo "dst_file: $dst_file"
if [ -f "$dst_file" ]
then
echo 'dst file exists, filling'
python whisper-fill.py "$src_file" "$dst_file"
else
echo 'dst file is missing, copying'
dst_dir=`echo "$dst_file" | sed 's#\(.*\)/.*$#\1#'`
mkdir -p "$dst_dir"
cp "$src_file" "$dst_file"
fi
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment