Giter Site home page Giter Site logo

ephemeral-scripts's Introduction

ephemeral-scripts

Boris HUISGEN [email protected]

Systemd units to prepare, use and backup Amazon EC2 ephemeral disks.

## ephemeral-disk

This service prepares the ephemeral disks of an Amazon EC2 instance. It will create at each system boot a swap partition - if enabled in configuration - and a data partition which will be mounted in the directory /ephemeral/data. If the partitions are already existing, nothing is done except mounting them. After mounting, the service starts all required service dependencies like Docker or your favorite SQL server. RAID software is also supported in case of several ephemeral disks to optimize IO performance.

LVM is used like this:

  • a volume group ephemeral for all disks
  • a logical volume swap for the swap partition
  • a logical volume data for the data partition

The volume group will have sufficient free space to allow snapshot creation and backup with the second script ephemeral-backup.

Installation

You need to install these dependencies:

# apt install make parted lvm2

If you want to use software RAID, add this one:

# apt install mdadm

Before configuring the service, you need to remove your ephemeral disks from the /etc/fstab file.

# cd ephemeral-disk/

# cp ephemeral-disk.dist ephemeral-disk
# vim ephemeral-disk

Edit the needed options.

# cp ephemeral-units.service.dist ephemeral-units.service
# vim ephemeral-units.service

# make install

Please check install output and fix all errors found on your system before enabling services.

### Usage

Start the ephemeral disk services:

# make enable
# make start

Check that swap and data partitions are created and mounted:

# cat /proc/swaps
# free -m
# lvs
# cd /ephemeral/data

To be sure verify your bootorder after a system restart:

# systemd-analyze plot > bootorder.svg

The unit ephemeral-units.service must be started before all units using the ephemeral storage.

## ephemeral-backup

This service backups the ephemeral data by creating a LVM snapshot of the ephemeral data partition. You need to create a shell script to execute your custom commands on the LVM snapshot which will be mounted in /ephemeral/snapshot.

### Installation

# cd ephemeral-backup/

# cp ephemeral-backup.dist ephemeral-backup
# vim ephemeral-backup

# cp backup.dist backup
# vim backup

# cp ephemeral-backup-daily.timer.dist ephemeral-backup-daily.timer

# make install

The timer ephemeral-backup-daily.timer will run periodically the service ephemeral-backup.service to start a backup.

### Usage

Start the ephemeral backup timer:

# make enable
# make start

To start a backup immediately:

# make backup

or at any time:

# systemctl start ephemeral-backup.service

FAQ

How to restore my ephemeral disk from a previous snasphot ?

To restore a previous snapshot, stop your services:

# systemctl stop ephemeral-units.service

Copy the snapshot archive file to restore and extract it:

# cd /ephemeral/data
# rm -fr .
# tar xzf /mnt/ebs/host/data-snap01012016.tar.gz

Restart the services:

# systemctl start ephemeral-units.service

How to upgrade a previous installation of these scripts ?

If your ephemeral disk has been partitioned by a previous version of these scripts, you need first to make a backup of your data:

# systemctl start ephemeral-backup.service

Then proceed to the uninstallation:

# cd ~/ephemeral-scripts/ephemeral-backup/
# make stop && make uninstall

# cd ~/ephemeral-scripts/ephemeral-disk/
# make stop && make uninstall

You can now install the latest scripts and restore your data.

ephemeral-scripts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.