Add cron-bkp-blockchain.sh; Update README
This commit is contained in:
parent
492cc9f9ab
commit
231e3f70af
|
@ -2,3 +2,5 @@ files/*.pub
|
|||
*.retry
|
||||
group_vars/all
|
||||
hosts
|
||||
out.txt
|
||||
err.txt
|
||||
|
|
64
README.md
64
README.md
|
@ -1,5 +1,61 @@
|
|||
# poa-devops
|
||||
DevOps scripts
|
||||
## DevOps scripts
|
||||
|
||||
Prepare for run: Change variables in group_vars/all.
|
||||
How run: ansible-playbook -i hosts site.yml
|
||||
### Setup blockchain backup from a node:
|
||||
1. connect to the node as `root`.
|
||||
|
||||
2. clone this repository to `root`'s home folder:
|
||||
```
|
||||
git clone https://github.com/poanetwork/poa-devops.git
|
||||
```
|
||||
|
||||
3. make sure `python` (v2.6+ or v3.5+) is installed on the node.
|
||||
|
||||
4. install `pip` and/or upgrade it to the newest version:
|
||||
```
|
||||
apt-get install python-pip
|
||||
pip install --upgrade pip
|
||||
```
|
||||
|
||||
5. upgrade `setuptools` to the newest version:
|
||||
```
|
||||
pip install --upgrade setuptools
|
||||
```
|
||||
|
||||
6. install `ansible`:
|
||||
```
|
||||
pip install ansible
|
||||
```
|
||||
|
||||
7. create `group_vars/all` file:
|
||||
```
|
||||
cp group_vars/all.example group_vars/all
|
||||
```
|
||||
and set the following variables:
|
||||
* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`)
|
||||
* `access_key` - s3 access key
|
||||
* `secret_key` - s3 secret key
|
||||
* `s3_bucket` - s3 bucket name
|
||||
|
||||
8. create `hosts` file:
|
||||
```
|
||||
cp hosts.example hosts
|
||||
```
|
||||
and set it to run on localhost:
|
||||
```
|
||||
[backup]
|
||||
localhost
|
||||
```
|
||||
|
||||
9. run playbook (still, do this on the node)
|
||||
```
|
||||
ansible-playbook -i hosts -c local site.yml
|
||||
```
|
||||
|
||||
19. if all is well, setup a cronjob to run every hour:
|
||||
```
|
||||
crontab -e
|
||||
```
|
||||
append the following line:
|
||||
```
|
||||
30 * * * * /bin/bash /root/poa-devops/cron-bkp-blockchain.sh
|
||||
```
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
#### line to add to crontab (remove leading '#')
|
||||
# 30 * * * * /bin/bash /root/poa-devops/cron-bkp-blockchain.sh
|
||||
####
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o
|
||||
|
||||
cd /root/poa-devops
|
||||
/usr/local/bin/ansible-playbook -i hosts -c local site.yml > out.txt 2> err.txt
|
Loading…
Reference in New Issue