예제 #1
0
파일: decommission.py 프로젝트: numan/ReDiS
def decommission(key, access, cluster, persistence="no"):
	events = Events(key, access, cluster)
	node = Host(cluster, events).get_node()
	def log(message, logging='warning'):
		events.log(node, 'Decommission', message, logging)

	log('start dommissioning', 'info')
	# make a last backup
	if "no" != persistence:
		log('make last backups, first RDB', 'info')
		# take the latest RDB and move it to S3
		rdb = backup.put_RDB(key, access, cluster, 'monthly')
		administration.set_RDB(key, access, cluster, rdb)

		# make a last snapshot
		log('and now a snapshot', 'info')
		snapshot = backup.make_snapshot(key, access, cluster, 'monthly')
		administration.add_snapshot(key, access, cluster, snapshot)

		delete_monitor()

	# we don't have to get rid any the volume, it is deleted on termination

	# change to the default (no persistence)
	log('remove redis.conf', 'info')
	os.system("/bin/rm -f /etc/redis/redis.conf")
	# and empty the cron as well
	log('empty the cron', 'info')
	os.system("/bin/echo | /usr/bin/crontab")

	# make sure we make a clean AMI, with all monit checks monitored
	log('finally, monitor all (monit), for making AMIs', 'info')
	os.system("/usr/sbin/monit monitor all")
예제 #2
0
파일: decommission.py 프로젝트: 9apps/ReDiS
def decommission(key, access, cluster, persistence="no"):
    events = Events(key, access, cluster)
    node = Host(cluster, events).get_node()

    def log(message, logging="warning"):
        events.log(node, "Decommission", message, logging)

    log("start dommissioning", "info")
    # make a last backup
    if "no" != persistence:
        log("make last backups, first RDB", "info")
        # take the latest RDB and move it to S3
        rdb = backup.put_RDB(key, access, cluster, "monthly")
        administration.set_RDB(key, access, cluster, rdb)

        # make a last snapshot
        log("and now a snapshot", "info")
        snapshot = backup.make_snapshot(key, access, cluster, "monthly")
        administration.add_snapshot(key, access, cluster, snapshot)

        delete_monitor()

        # we don't have to get rid any the volume, it is deleted on termination

        # change to the default (no persistence)
    log("remove redis.conf", "info")
    os.system("/bin/rm -f /etc/redis/redis.conf")
    # and empty the cron as well
    # log('empty the cron', 'info')
    # os.system("/bin/echo | /usr/bin/crontab")

    # make sure we make a clean AMI, with all monit checks monitored
    log("finally, monitor all (monit), but 'redis' and slave", "info")
    os.system("/usr/bin/monit unmonitor redis")
    os.system("/usr/bin/monit unmonitor slave")
예제 #3
0
	os.system("/bin/gzip -df {0}.gz".format(src))
	#print os.system("/bin/cat {0}".format(src))

# for convenience we can call this file to make backups directly
if __name__ == '__main__':
	s3 = S3Connection(sys.argv[2],sys.argv[3])

	# get the bucket, from the cluster name
	name = os.environ['REDIS_NAME'].strip()
	hosted_zone = os.environ['HOSTED_ZONE_NAME'].rstrip('.')
	cluster = "{0}.{1}".format(name, hosted_zone)
	bucket = s3.get_bucket( cluster.replace('.', '-'))

	if "rdb" == sys.argv[1]:
		create_bucket(sys.argv[2], sys.argv[3], cluster)
		key = put_RDB(sys.argv[2], sys.argv[3], cluster, sys.argv[4])
		administration.set_RDB(sys.argv[2], sys.argv[3], cluster, key)
	elif "snapshot" == sys.argv[1]:
		backup = make_snapshot(sys.argv[2], sys.argv[3], cluster, sys.argv[4])
		administration.add_snapshot(sys.argv[2], sys.argv[3],
											cluster, backup)
	elif "purge" == sys.argv[1]:
		snapshots = administration.get_expired_snapshots(sys.argv[2],
											sys.argv[3], cluster)
		purge_snapshots(sys.argv[2], sys.argv[3], cluster, snapshots)

	elif "purge-all" == sys.argv[1]:
		snapshots = administration.get_all_snapshots(sys.argv[2],
											sys.argv[3], cluster)
		purge_snapshots(sys.argv[2], sys.argv[3], cluster, snapshots)