VGH Scripts

A collection of custom scripts used on VladGh.com

Instalation

Some system wide dependencies should be installed first:

  • ruby 1.8 or 1.9
  • rubygems (if ruby 1.8)
  • ruby-dev
  • build-essential
  • libxslt & libxslt-dev
  • libxml2 & libxml2-dev

Add this line to your application's Gemfile:

gem 'vgh'

And then execute:

$ bundle

Or install it yourself as:

$ gem install vgh

Configuration

This gem looks for the configuration file inside the following folders

  • /etc/vgh
  • ~/.vgh
  • --confdir (specified in the command line options)

This gem checks if the file exists and if it is in a correct YAML format.

It should have the following format (where the keys are symbols): # Comment :key: 'value' :string: 'string value' :integer: 123 :boolean: true/false :array: - '1st' - '2nd' :hash: - :sub_key: 'sub value'

An example of the configuration file can be found in this gem's directory. You can copy it by using the --example=PATH command line option.

Ex: mkdir /etc/vgh vgh --example=/etc/vgh

Read the config.yml.example for a list of configuration options.

Command line options

The following command line options are available:

[+ApplicationName+] Specify the application you want to run. For a list of available apps see Applications below. [--confdir=~/.vgh] Specify the desired directory in which the configuration files reside. [+-v+ --[no-]verbose] Specify whether to display messages on the screen or not. [+-l+ --[no-]logging] Specify whether to log messages or not. [+-g+ +--gemdir+] Gem files location. [+-h+ +--help+] Displays this list. [+-V+ +--version+] Displays the version number.

Applications

EC2-Backup

[/bin/vgh ec2-backup]

==== Description
This app creates a snapshot of the attached EBS volumes. It also deletes
snapshots older than the expiration period specified in the configuration
file. It is intended to be used as a cron job on an AWS instance running
Ubuntu.

You can also backup a remote instance, if you specify an +:instance+ or
+fqdn+ value in the configuration file. But if you do so, you loose the
ability to suspend MySQL or Logical Volumes.

If a MySQL server is running, and the script has access to the administrator
credentials, then it closes all open tables and locks all tables for all
databases with a global read lock. Everything is unlocked at the end of the
script even if errors occur during the snapshot process. <em>You need to
provide the necessary mysql credentials in the +ec2-backup.config.yml+ file.
</em>

If Logical Volumes are found on the system then they are suspended for the
duration on the snapshot process.
Suspending a volume becomes useful if you want for example a consistent
EC2 snapshot of it. Any I/O that has already been mapped by the device but
has not yet completed will be flushed. Any further I/O to that device will
be postponed for as long as the device is suspended.


==== Intended usage
# Cron Job:
0 */6 * * * vgh ec2-backup -l

Checkpoint

[/bin/vgh checkpoint]

==== Description
This app looks for volumes tagged with the 'CHECKPOINT' key attached to the
current instance, and creates snapshots for them.
It is intended to be used as a cron job on an AWS instance running
Ubuntu.

MySQL flushing and LVM suspending specified above in the EC2-Backup app, work
the same.


==== Intended usage
# Cron Job:
0 */6 * * * vgh checkpoint -l

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request (Using Pull Requests)

License

See LICENSE

Changelog

See CHANGELOG