A collection of custom scripts used on VladGh.com
Some system wide dependencies should be installed first:
apt-get install libxslt-dev libxml2-dev
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install vgh
This gem looks for the following configuration files inside “/etc/vgh” or the --confdir specified in:
The main configuration file for this gem. This file should include the AWS specific configuration. Available values:
:access_key_id - [String] Your AWS credentials
:secret_access_key - [String] Your AWS credentials
:region - optional [String] Your current instance's region. Ex: 'us-west-1'
The application specific configuration (see Applications below for a list of available apps and values).
This gem checks if the files exists and if they are in a correct YAML format.
All files 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'
Example configuration files can be found in this gem's directory. You can find were that is by specifying the --gemdir command line option.
Ex: vgh --gemdir
Command line options
The following command line options are available:
Specify the application you want to run. For a list of available apps see Applications below.
- -c --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.
- /bin/vgh ec2-backup
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. You need to provide the necessary mysql credentials in the ec2-backup.config.yml file.
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.
:expiration – required [Integer] Number of days to keep the snapshots.
# Ex: :expiration: 7
:mysql_user – required [String] The MySQL user that can flush the tables.
# Ex: :mysql_user: 'dbadmin'
:mysql_pwd – required [String] The password of the above MySQL user.
# Ex: :mysql_pwd: 'MyStrongPassword'
:instance – optional [String] The id of the remote instance you want to backup.
# Ex: :instance: 'i-12345678'
:fqdn – optional [String] The FQDN of the remote instance you want to backup.
# Ex: :fqdn: 'MyServer.Example.com'
# Cron Job: 0 */6 * * * vgh ec2-backup -l
Create your feature branch (git checkout -b my-new-feature)
Commit your changes (git commit -am 'Add some feature')
Push to the branch (git push origin my-new-feature)
Create new Pull Request (Using Pull Requests)