-
connect to the node as
root
. -
clone this repository to
root
's home folder:
git clone https://github.com/poanetwork/poa-devops.git
cd poa-devops
-
make sure
python
(v2.6+ or v3.5+) is installed on the node. -
install
pip
and/or upgrade it to the newest version:
apt-get install python-pip
pip install --upgrade pip
- upgrade
setuptools
to the newest version:
pip install --upgrade setuptools
- install
boto
andboto3
packages:
pip install boto boto3
- install
ansible
:
pip install ansible
- create
group_vars/backup
file:
cp group_vars/backup.example group_vars/backup
and set the following variables:
poa_role
- node's role (one ofbootnode
,validator
,moc
,explorer
,netstat
)backup_parity_data
-true
/false
- backup wholeparity_data
folder "as is" or not (default:true
)backup_parity_blocks
-true
/false
- use or notparity export blocks
to create a file with exported blocks and backup it (default:true
)access_key
- s3 access keysecret_key
- s3 secret keys3_bucket
- s3 bucket namenode_name
- short descriptive name of the node (e.g.sokol-arche
). It will be used as part of a backup file name, so it must be lowercase, must not contain spaces, commas, etc
- create
hosts
file:
touch hosts
and set it to run backup
on localhost:
[backup]
localhost
- run playbook (still, do this on the node)
ansible-playbook -i hosts -c local site.yml
- if all is well, setup a cronjob to run every hour:
crontab -e
append the following line:
30 * * * * /bin/bash /root/poa-devops/bkp-blockchain-cron.sh
- configure logrotate to archive old log files. Create file
/etc/cron.hourly/poa-devops-logrotate
with the following content:
#!/bin/bash
/usr/sbin/logrotate /root/poa-devops/bkp-blockchain-logrotate.conf
and set permission to run it:
chmod 755 /etc/cron.hourly/poa-devops-logrotate
Must be done under root
account
-
place backup file to the user's home directory, e.g.
/home/bootnode
(or/home/moc
, etc) -
stop netstats (if it's installed) and parity
# may fail if netstats is not installed, ignore it then:
systemctl stop poa-netstats
systemctl stop poa-parity
- backup your current
parity_data
# replace bootnode with other role's name if necessary (e.g. moc, validator, etc)
cd /home/bootnode
mv parity_data parity_data.bkp.$(date -u +%Y%m%d-%H%M%S)
- unpack
parity_data
folder from backup
# exact filename will be different
tar -xzf 20180127-134045-bootnode-sokol-archive-parity_data.tar.gz
- make sure that
bootnode
(ormoc
, etc) is owner of the unpacked directory
ls -lh
check owner of the parity_data
, if it's another user, run
# replace bootnode with correct user name if necessary (e.g. moc, validator, etc)
chown -R bootnode:bootnode parity_data
- restart parity and netstats (if it's installed)
systemctl start poa-parity
# unnecessary if netstats is not installed:
systemctl start poa-netstats
- open
NETSTATS_URL
in your browser to see if node is up and accepts blocks. If not, explore parity logs in/home/bootnode/logs/parity.log
or try to start parity manually to see if it fails at startup:
# assuming you're still in home folder
./parity --config node.toml
Parity docs: https://github.com/paritytech/parity/wiki/FAQ:-Backup,-Restore,-and-Files#how-do-i-backup-my-blockchain
Must be done under root
account_
-
place backup file to the user's home directory, e.g.
/home/bootnode
(or/home/moc
, etc) -
stop netstats (if it's installed) and parity
# may fail if netstats is not installed, ignore it then:
systemctl stop poa-netstats
systemctl stop poa-parity
- backup your current
parity_data
# replace bootnode with other role's name if necessary (e.g. moc, validator, etc)
cd /home/bootnode
cp -a parity_data parity_data.bkp.$(date -u +%Y%m%d-%H%M%S)
- remove current chain
rm -rf parity_data/cache parity_data/chains
- unpack
parity_blocks.rlp
file from backup
# exact filename will be different
gunzip 20180127-134045-bootnode-sokol-archive-parity_blocks.rlp.gz
- import blocks from backup
./parity --config node.toml import 20180127-134045-bootnode-sokol-archive-parity_blocks.rlp
- make sure that
bootnode
(ormoc
, etc) is owner ofparity_data
and all its subfolders, most importantly newly createdparity_data/cache
andparity_data/chains
ls -lh
ls -lh parity_data
if owner is another user, run
# replace bootnode with correct user name if necessary (e.g. moc, validator, etc)
chown -R bootnode:bootnode parity_data
- restart parity and netstats (if it's installed)
systemctl start poa-parity
# unnecessary if netstats is not installed:
systemctl start poa-netstats
- open
NETSTATS_URL
in your browser to see if node is up and accepts blocks. If not, explore parity logs in/home/bootnode/logs/parity.log
or try to start parity manually to see if it fails at startup:
# assuming you're still in home folder
./parity --config node.toml