Skip to content

Instantly share code, notes, and snippets.

View pixie79's full-sized avatar

Mark Olliver pixie79

  • UK
  • 12:22 (UTC +01:00)
View GitHub Profile
@pixie79
pixie79 / to_cloud.rb
Created November 16, 2012 09:17
Rackspace Cloud File - push large files to cloud daily as a backup
################
# This script was written to take a large file over 2G and split it into smaller files then push these to Rackspace's cloud files daily.
# The following day it will remove the next backup once the current backup has been pushed.
# It expects the filename and path to the file to be backed up to be passed to it as a calling argument
# Sample path - /opt/backup/store/Server1.Thu.2 # Where Thu is day of the week of the backup and 2 is the week of the month.
# Update XXXX with the appropriate values in the appropriate places
#!/usr/bin/env ruby
require 'rubygems'
require 'cloudfiles'
@pixie79
pixie79 / cloud_find.sh
Created November 16, 2012 09:19
Cron Backup file find script for passing arguments to to_cloud.rb
#!/bin/bash
# This script is expected to be run once every ten minutes
#
list="/tmp/backup_list_`date +%s`"
find $1 -mmin -800 -type f -print > $list
for i in `cat $list`
do
echo "Backing up: "$i
/usr/local/bin/to_cloud.rb $i
@pixie79
pixie79 / vz-clean.bash
Created February 13, 2013 12:14
OpenVZ: Conversion of a OEL/CentOS virtual server to a Package template cache
#!/bin/bash
# The raw copy of the virtual server should be extracted to /vz/private/$CTID from there it can be customised using thi script to get it ready for packaging as an openvz tempalte.
CTID=101
export CTID
echo "none /dev/pts devpts rw 0 0" > /vz/private/$CTID/etc/fstab
echo "proc /proc proc defaults 0 0" >> /vz/private/$CTID/etc/fstab
echo "tmpfs /dev/shm tmpfs defaults 0 0" >> /vz/private/$CTID/etc/fstab
mkdir /vz/private/$CTID/dev
#!/usr/bin/env ruby
# This script downloads the current backup from Rackspace Cloud file storage as made by the too cloud script and mounts the raw disk image checking the contents of the /var/log/date file for validity of the current date. (which was created by an hourly cronjob on the live running guest before the backup was taken).
require 'rubygems'
require 'cloudfiles'
guest = ARGV[0]
path = ARGV[1] ||= "/opt/dump"
container = ARGV[2] ||= "eudc"
@pixie79
pixie79 / from_cloud_single.rb
Created February 13, 2013 12:22
This file works with from_cloud.rb and allows you to download any missing or complete any partially downloaded cloud files.
#!/usr/bin/env ruby
require 'rubygems'
require 'cloudfiles'
guest = ARGV[0]
path = ARGV[1] ||= "/opt/dump"
container = ARGV[2] ||= "eudc"
def list_file(guest, container, cf, path)
@pixie79
pixie79 / setItimer.js
Created March 7, 2013 16:18
NodeJS set an Itimer
var blah = function(x, y, z) {
return function() {
console.log(x,y,z)
}
}
setTimeout(blah(1,2,3), 100);
@pixie79
pixie79 / bootstrap.rb
Created March 13, 2013 09:39
Bootstrap for adding an encrypted data key
mkdir -p /etc/chef
(
cat <<'EOP'
<%= validation_key %>
EOP
) > /tmp/validation.pem
awk NF /tmp/validation.pem > /etc/chef/validation.pem
rm /tmp/validation.pem
@pixie79
pixie79 / cpu-alert.py
Created March 13, 2013 12:21
Trigger for working our cpu alert levels needed for sensu or nagios
#!/usr/bin/env python
# CPU Alert levels - based on number of CPU in machine
from __future__ import division
import multiprocessing
cpu = multiprocessing.cpu_count()
if cpu <= 2:
cpu = 3
@pixie79
pixie79 / test.py
Last active December 15, 2015 02:29
startup
__init__.py
mount
__init__.py
mount.py
passwd
__init__.py
getpasswd.py
######
@pixie79
pixie79 / path.sh
Created April 8, 2013 14:42
sensu - check path
#!/bin/bash
#
# Evaluate system path
#
echo "System PATH - $PATH"
exit 2