1 定期备份数据库
#!/bin/bash
today=$(date "+%Y%m%d")
mysqldump -udbu -pdddd coucou > ~/test_${today}.sql
cd /home/ubuntu/ && tar zcvf test_$today.tar.gz test_${today}.sql > /dev/null;
\rm test_${today}.sql;
mv test_${today}.tar.gz /home/ubuntu/db_bak/;
2 测试服务器自动更新脚本
cd /home/ubuntu/coucou;
branch_name=$(git symbolic-ref -q HEAD);
if [ $branch_name = "refs/heads/test_tmp" ] ;then
echo "on branch test"
else
echo "on branch $branch_name"
echo "exit ......"
exit 1
fi
db_name=$(make db);
if [ "$db_name" = "SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://dbu:dddd@localhost/coucou?" ] ;then
echo "on db cucou"
else
echo "on db $db_name"
echo "exit ......"
exit 1
fi
sudo su ubuntu -c"
cd /home/ubuntu/coucou;
git pull origin test_tmp;
"
sudo su ubuntu -c"sudo supervisorctl restart coucou"
sudo su ubuntu -c"sudo supervisorctl stop poll_block celery_default celery_auth celery_eth_task celery_bounty celery_notify celery_eth_out poll_bet poll_usdt poll_btc celery_usdt_task"
sudo su ubuntu -c"cd /home/ubuntu/coucou;/home/ubuntu/.virtualenvs/coucou/bin/python manage.py db upgrade"
sudo su ubuntu -c"sudo supervisorctl start poll_block celery_default celery_auth celery_eth_task celery_bounty celery_notify celery_eth_out poll_bet poll_usdt poll_btc celery_usdt_task"
sudo su ubuntu -c"sudo supervisorctl status"