Simple snapshots tool for Yandex.Cloud
Automatically create snapshots for virtual machines from config file. Sequence for running instances: stop VM – create snapshot – start VM, for stopped instances just create snapshot.
Automatic deletion of snapshots older than N days for instances from config. The lifetime is specified in the config file.
pip install -r requirements.txt
- Create config dir
mkdir -p ~/.ya-tools
- Edit
vim ydnx.cfg.example
- Insert OAuth-token into config file.
- Enter instance ID into config file. For multiple instances enter space separated IDs (without the quotes).
- Enter snapshots lifetime in days.
- Move file
mv yndx.cfg.example ~/.ya-tools/yndx.cfg
Example config file:
[Auth]
OAuth_token = AQAAAAYqwerty1qwerty2qwerty3
[Instances]
# Space separated instance IDs
IDs = efqwer2tyu3qwert7yz ef1xzcvbnm2qwerty1qwe
[Snapshots]
# Specify the lifetime of snapshots in days
Lifetime = 14
akimrx@thinkpad:~/github/yandex-cloud-tools$ ./snapshoter.py --help
usage: snapshoter.py [-h] [-v] [-c] [-d] [-f]
Snapshots-tools. To work, you must add instances id to the config file (space separated if multiple)
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-c, --create create snapshots for VMs
-d, --delete delete all old snapshots for instances
-f, --full create snapshots and delete old snapshots for instances
You can run the script manually as needed, or create a task in the scheduler Cron.
If you use the scheduler Cron, you must place the config file in your home directory (/home/username/yndx.cfg).