This is a hands-on way to pull down a set of MySQL dumps from Amazon S3 and restore your database with it
Sister Document - Backup MySQL to Amazon S3 - read that first
# Set our variables
export mysqlpass="ROOTPASSWORD"
import MySQLdb as mdb | |
import pandas as pd | |
con = mdb.connect(‘127.0.0.1’, ‘root’, ‘password’, ‘database_name’); | |
with con: | |
cur = con.cursor() | |
cur.execute(“select random_number_one, random_number_two, random_number_three from randomness.a_random_table”) | |
rows = cur.fetchall() | |
df = pd.DataFrame( [[ij for ij in i] for i in rows] ) | |
df.rename(columns={0: ‘Random Number One’, 1: ‘Random Number Two’, 2: ‘Random Number Three’}, inplace=True); | |
print(df.head(20)) |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
# if you want a list of integers as your random data set | |
df = pd.DataFrame(np.random.randint(0,20,size=(20, 2)), columns=list('PQ')) | |
# if you want a list of random decimal numbers as your random data set | |
df = pd.DataFrame(np.random.randn(20,2), columns=list('PQ')) | |
# plot the data | |
plt.scatter(df.P,df.Q, alpha=0.5) | |
# plt.show() |
#!/bin/sh | |
credentials() | |
{ | |
username=loader | |
password=L0#De&1234 | |
hostname=127.0.0.1 | |
database=yourdatabasename | |
postgres_user=postgresusr |
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |
PYTHON_PATH=$(which python) | |
PSQL_PATH=$(which psql) | |
MYSQL_SCRIPT='mysql2file.py' | |
MYSQL_SERVER= | |
MYSQL_PORT=3306 | |
MYSQL_DATABASE= | |
MYSQL_USER= | |
MYSQL_PASSWORD= |
import os | |
import sys | |
import subprocess | |
import instaLooter | |
basepath = "/Users/kovid.rathee/Desktop/instaLooter/" | |
accounts = ['rupikaur_','fursty','tropicalratchet','dylankato','asyrafacha','tomashavel','runawayueli','dreamingandwandering'] | |
for account in accounts: | |
dir = basepath + account | |
print(os.path.isdir(dir)) | |
if not os.path.exists(dir): |
#!/bin/bash | |
# Disclaimer - make backups, use at your own risk. | |
# | |
# Based on this comment: http://stackoverflow.com/a/13944924/843067 | |
# Views and stored procedures have to be done separately. | |
OLDDB="old_db_name" | |
NEWDB="new_db_name" | |
MYSQL="mysql -u root -pyour_password " |
This is a hands-on way to pull down a set of MySQL dumps from Amazon S3 and restore your database with it
Sister Document - Backup MySQL to Amazon S3 - read that first
# Set our variables
export mysqlpass="ROOTPASSWORD"
#!/bin/sh | |
## backup each mysql db into a different file, rather than one big file | |
## as with --all-databases. This will make restores easier. | |
## To backup a single database simply add the db name as a parameter (or multiple dbs) | |
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is | |
## Create the user and directories | |
# mkdir -p /var/backups/mysql/databases | |
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup | |
## Remember to make the script executable, and unreadable by others |