Last active
December 24, 2015 02:23
-
-
Save artzub/21124e49661525a51426 to your computer and use it in GitHub Desktop.
backup for youtrack and hub and upsource hard
This file contains hidden or 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/bash | |
##### | |
# install yadisk | |
# | |
# $ echo "deb http://repo.yandex.ru/yandex-disk/deb/ stable main" | tee -a /etc/apt/sources.list.d/yandex.list > /dev/null && wget http://repo.yandex.ru/yandex-disk/YANDEX-DISK-KEY.GPG -O- | apt-key add - && apt-get update && apt-get install -y yandex-disk | |
# | |
# $ yandex-disk setup | |
# | |
# add cron command | |
# | |
# $ crontab -e | |
# append | |
# 0 5 * * */3 /root/backup_yhu.sh | |
##### | |
### | |
# docs | |
# | |
# https://www.jetbrains.com/upsource/help/2.0/backup.html | |
# https://confluence.jetbrains.com/display/YTD65/Upgrading+YouTrack+with+ZIP+Distribution | |
# https://www.jetbrains.com/upsource/help/2.0/upgrade.html | |
### | |
yandex-disk start | |
#--exclude-dirs="db_backups,upload_backups" | |
jbdir="/usr/jetbrains" | |
root_dir="backups_yhu" | |
year=`date +%Y` | |
month=`date +%m` | |
key=`date +%Y_%m_%w` | |
echo "services are stoping" | |
$jbdir/youtrack/bin/youtrack.sh stop | |
$jbdir/upsource/bin/upsource.sh stop | |
$jbdir/hub/bin/hub.sh stop | |
echo "hard backup data and conf" | |
[ -d /mnt/yadrive/$root_dir/ ] || mkdir /mnt/yadrive/$root_dir/ | |
[ -d /mnt/yadrive/$root_dir/$year ] || mkdir /mnt/yadrive/$root_dir/$year | |
full=/mnt/yadrive/$root_dir/$year/$month | |
[ -d $full ] || mkdir $full | |
cur=hub | |
archname="$cur_$key.tar.gz" | |
echo "backup $cur into $archname" | |
tar -zcf /tmp/$archname $jbdir/$cur/data $jbdir/$cur/conf | |
[ -d $full/$cur ] || mkdir $full/$cur | |
mv /tmp/$archname $full/$cur/$archname -f | |
#======================================== | |
cur=youtrack | |
archname="$cur_$key.tar.gz" | |
echo "backup $cur into $archname" | |
tar -zcf /tmp/$archname $jbdir/$cur/data $jbdir/$cur/conf | |
[ -d $full/$cur ] || mkdir $full/$cur | |
mv /tmp/$archname $full/$cur/$archname -f | |
#======================================== | |
cur=upsource | |
archname="$cur_$key.tar.gz" | |
echo "backup $cur into $archname" | |
tar -zcf /tmp/$archname $jbdir/$cur/data $jbdir/$cur/conf | |
[ -d $full/$cur ] || mkdir $full/$cur | |
mv /tmp/$archname $full/$cur/$archname -f | |
echo "sync with yandex" | |
i=0 | |
while true; do | |
yap=`yandex-disk status | grep "Sync progress:" | sed 's/ //g'` | |
yas=`yandex-disk status | grep "Synchronization core status:" | cut -d':' -f2 | sed 's/ //g'` | |
echo "status: $yas | $yap"; | |
if [ $i -gt 1800 ]; then | |
break; | |
fi | |
let i++ | |
if [ "$yas" != "idle" ]; then | |
sleep 1 | |
else | |
break; | |
fi | |
done | |
yandex-disk stop | |
sleep 60 | |
killall -s9 yandex-disk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment