git clone https://github.com/johnashu/digital_ocean_volume_resize.git
To update use git pull
Rename .env.example to .env and edit the following variables:
cp .env.example .env
nano .env
Generate a token in the API section of your provider.
Use whole numbers for the Percentages
Add Email information - See your email provider..
If using Linnode, make sure to setup Email https://www.linode.com/community/questions/19082/i-just-created-my-first-linode-and-i-cant-send-emails-why
Add Vstats Token. On Telegram -> @vStatsBot - use command
/token
to generate a token.
Toggle the
SEND_EMAIL
&SEND_ALERT_TO_VSTATS
chooseTrue
/False
to send alerts to these 2.
# Choose DO (Digital Ocean) / LN (Linnode) / XX (Any other with no auto Resize - Alerts only - provide name in PROVIDER_NAME)
PROVIDER=DO
VOLUME_NAME=volume_sfo3_02
PROVIDER_NAME=False # Provide name if PROVIDER=XX (E.G. Hetzner)
# API Key DO
TOKEN=<DIGITAL_OCEAN_API_KEY>
# # API KEY LN
# TOKEN=<LINNODE_API_KEY>
# Trigger options
INCREASE_BY_PERCENTAGE=5
BELOW_THIS_PERCENT_TO_RESIZE=5
# Hours in-between checks
HOURS=6
# Email Options
SEND_EMAIL=True
EMAIL_SMTP=smtp.123-reg.co.uk
EMAIL_PASS=<EMAIL_PASSWORD>
EMAIL_FROM=john@maffaz.com
EMAIL_TO=mennovandevlees@gmail.com
# Vstats Telegram Bot Options
SEND_ALERT_TO_VSTATS=True
VSTATS_TOKEN=<VSTATS_TOKEN>
#Monitoring alerts - Space Left
SPACE_LEFT_ALERT=True
sudo apt update && sudo apt upgrade -y
apt install python3-pip
pip3 install -r requirements.txt
python3 main.py
NOTE: You will need root access. If you do not have this or would prefer not to then you can create a tmux session under your user and skip the below. If you are unsure of the location of
/path/to/digital_ocean_volume_resize
navigate to the dir and run the commandpwd
(Path Current Directoy) This will give you the location , i.e./maffaz/harmony/digital_ocean_volume_resize
cat<<-EOF > /etc/systemd/system/resize_volume.service
[Unit]
Description=resize_volume daemon
After=network-online.target
[Service]
Type=simple
Restart=always
RestartSec=1
User=<USER>
WorkingDirectory=/path/to/digital_ocean_volume_resize
ExecStart=python3 main.py
SyslogIdentifier=resize_volume
StartLimitInterval=0
LimitNOFILE=65536
LimitNPROC=65536
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo chmod 755 /etc/systemd/system/resize_volume.service
sudo systemctl enable resize_volume.service
sudo service resize_volume start
sudo service resize_volume status
tail -f /var/log/syslog
journalctl -xefu resize_volume
log file is in logs/data.log
Please be aware that there are discrepencies between what is Reported by the Provider and what is reported by the System
In the Email and alerts you will see 2 seperate values.
-
Resized Digital Ocean Volume volume-sfo3-02 resizing from 649 GB -> 655 GB
This is the Size that will be displayed in the Volume when you log in to your provider website and check your volume online.
-
System Original Size : 644 | System New Size: 650
This is the size that will be displayed on your node if you run the command
df -h | grep /mnt/<VOLUME_NAME>
i.e.
df -h | grep /mnt/volume_sfo3_02
/dev/sda 650G 412G 210G 67% /mnt/volume_sfo3_02