Skip to content

Instantly share code, notes, and snippets.

View eduherraiz's full-sized avatar

Edu Herraiz eduherraiz

View GitHub Profile
import psycopg2
import time
def query(select):
try:
conn = psycopg2.connect("dbname=test user=test password=12345678")
cur = conn.cursor()
cur.execute(select)
conn.commit()
conn.close()
2014-07-03 17:57:11 CEST LOG: database system was interrupted; last known up at 2014-07-03 16:15:27 CEST
2014-07-03 17:57:11 CEST LOG: starting point-in-time recovery to 2014-07-03 17:00:00+02
wal_e.operator.backup INFO MSG: begin wal restore
STRUCTURED: time=2014-07-03T15:57:11.798960-00 pid=11678 action=wal-fetch key=s3://apsl-wale/lohap1/wal_005/00000007.history.lzo prefix=lohap1/ seg=00000007.history state=begin
2014-07-03 17:57:12 CEST LOG: incomplete startup packet
wal_e.blobstore.s3.s3_util INFO MSG: completed download and decompression
DETAIL: Downloaded and decompressed "s3://apsl-wale/lohap1/wal_005/00000007.history.lzo" to "pg_xlog/RECOVERYHISTORY"
STRUCTURED: time=2014-07-03T15:57:12.225174-00 pid=11678
wal_e.operator.backup INFO MSG: complete wal restore
STRUCTURED: time=2014-07-03T15:57:12.227431-00 pid=11678 action=wal-fetch key=s3://apsl-wale/lohap1/wal_005/00000007.history.lzo prefix=lohap1/ seg=00000007.history state=complete
restore_command = '/usr/bin/envdir /etc/wal-e.d/env /usr/local/bin/wal-e wal-fetch "%f" "%p"'
# Escoge, descomentando,que punto en el tiempo quieres recuperar
#recovery_target_time = '2014-07-01 09:07:00'
#recovery_target_time = 'latest'
#pause_at_recovery_target = false ## Descomentar esta linea si no queremos que se quede pausado el postgres despues de recuperar
#recovery_end_command = ''
############################
POSTGRESQL LOGS WAL-E
############################
## SUBIDA CORRECTA
wal_e.worker.upload INFO MSG: begin archiving a file
DETAIL: Uploading "pg_xlog/00000001000000000000000C" to "s3://cursopostgres-wale/test-edu/wal_005/00000001000000000000000C.lzo".
STRUCTURED: time=2014-10-28T08:33:49.736120-00 pid=11210 action=push-wal key=s3://cursopostgres-wale/test-edu/wal_005/00000001000000000000000C.lzo prefix=test-edu/ seg=00000001000000000000000C state=begin
2014-10-28 10:56:17 CET LOG: database system was interrupted; last known up at 2014-10-28 10:33:22 CET
2014-10-28 10:56:17 CET LOG: starting archive recovery
wal_e.operator.backup INFO MSG: begin wal restore
STRUCTURED: time=2014-10-28T09:56:17.253425-00 pid=22302 action=wal-fetch key=s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo prefix=test-edu/ seg=000000010000000000000020 state=begin
2014-10-28 10:56:17 CET LOG: incomplete startup packet
wal_e.blobstore.s3.s3_util INFO MSG: completed download and decompression
DETAIL: Downloaded and decompressed "s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo" to "pg_xlog/RECOVERYXLOG"
STRUCTURED: time=2014-10-28T09:56:18.061708-00 pid=22302
wal_e.operator.backup INFO MSG: complete wal restore
STRUCTURED: time=2014-10-28T09:56:18.064113-00 pid=22302 action=wal-fetch key=s3://cursopostgres-wale/test-edu/wal_005/000000010000000000000020.lzo prefix=test-edu/ seg=000000010000000000000
#!/bin/bash
# $Id: check_slave_replication.sh 3421 2013-08-09 07:52:44Z jmorano $
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
## Master (p_) and Slave (s_) DB Server Information
Wed Oct 29 14:56:10 2014 - *** /var/pywww/htv/htv.reload has been touched... grace them all !!! ***
Wed Oct 29 14:56:10 2014 - ...gracefully killing workers...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 5 (pid: 31432)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 1 (pid: 31428)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 4 (pid: 25261)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 2 (pid: 31429)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 3 (pid: 31430)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 8 (pid: 10814)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 6 (pid: 31433)...
Wed Oct 29 14:56:10 2014 - Gracefully killing worker 9 (pid: 8630)...
@eduherraiz
eduherraiz / upgrade_libc6.sh
Created January 28, 2015 23:39
GHOST upgrade libc6 ubuntu 11.10
#!/bin/bash
# Upgrade libc6 for security problem GHOST on ubuntu 11.10
# We are using the ubuntu packages from the 12.04 and installing by hand
wget http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc-bin_2.15-0ubuntu10.10_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6_2.15-0ubuntu10.10_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc-dev-bin_2.15-0ubuntu10.10_amd64.deb
wget http://security.ubuntu.com/ubuntu/pool/main/e/eglibc/libc6-dev_2.15-0ubuntu10.10_amd64.deb
dpkg -i libc-bin_2.15-0ubuntu10.10_amd64.deb
dpkg -i libc6_2.15-0ubuntu10.10_amd64.deb
From d5dd6189d506068ed11c8bfa1e1e9bffde04decd Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Mon, 21 Jan 2013 17:41:28 +0100
Subject: [PATCH] Fix parsing of numeric hosts in gethostbyname_r
---
ChangeLog | 14 +++++++++
NEWS | 12 ++++----
nss/Makefile | 2 +-
nss/digits_dots.c | 73 +++++++++++++----------------------------------
@eduherraiz
eduherraiz / update_libc6.sh
Created January 30, 2015 08:16
Procedure to update libc6 on debian 5 (lenny), patching, compiling and generating debs. Patch for GHOST CVE-2015-0235
#!/bin/bash
# Update libc6 on Debian 5 lenny, compiling with a patch from the deb code
# Note: This script is not tested, writed to preserve the procedure, be careful.
# Get the package source
apt-get update && apt-get source libc6; apt-get build-dep libc6
# Patch it
wget https://gist.githubusercontent.com/eduherraiz/ea6884ca90622dede558/raw/87e14d4280f2d75f77f17e26d6cd8b4e0237f015/cve-2015-0235-lenny.diff --no-check-certificate -O glibc-2.7/debian/patches/all/cve-2015-0235-lenny.diff