Skip to content

Instantly share code, notes, and snippets.

View zach-adams's full-sized avatar

Zach Adams zach-adams

View GitHub Profile
@zach-adams
zach-adams / wp-modifydb.php
Created August 31, 2016 21:30 — forked from jcanfield/wp-modifydb.php
Serialized PHP Search and Replace
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@zach-adams
zach-adams / MysqlDatabase.php
Last active June 22, 2016 17:14
Backup Manager with Include/Ignore tables
<?php namespace App\Backups;
use BackupManager\Databases\Database;
/**
* Class MysqlDatabase
* @package BackupManager\Databases
*/
class MysqlDatabase implements Database {
@zach-adams
zach-adams / vagrant_halt_custom
Created July 15, 2015 17:07
A copy of the db_backup script that automatically copies the backups to the sync folder
#!/bin/bash
#
# Create individual SQL files for each database. These files
# are imported automatically during an initial provision if
# the databases exist per the import-sql.sh process.
mysql -e 'show databases' | \
grep -v -F "information_schema" | \
grep -v -F "performance_schema" | \
grep -v -F "mysql" | \
grep -v -F "test" | \
@zach-adams
zach-adams / sync-sql.sh
Created July 15, 2015 17:04
A copy of import-sql.sh with edits to refresh databases on vagrant up
#!/bin/bash
#
# Sync the sql files in the sync folder
#
# The files in the {vvv-dir}/database/sync/ directory should be created by
# mysqldump or some other export process that generates a full set of SQL commands
# to create the necessary tables and data required by a database.
#
# For a sync to work properly, the SQL file should be named `db_name.sql` in which
# `db_name` matches the name of a database already created in {vvv-dir}/database/init-custom.sql
@zach-adams
zach-adams / Vagrantfile
Last active April 13, 2018 22:52
A modified Vagrantfile to tell VVV to run import-sql script on up
# Vagrant Triggers
#
# If the vagrant-triggers plugin is installed, we can run various scripts on Vagrant
# state changes like `vagrant up`, `vagrant halt`, `vagrant suspend`, and `vagrant destroy`
#
# These scripts are run on the host machine, so we use `vagrant ssh` to tunnel back
# into the VM and execute things. By default, each of these scripts calls db_backup
# to create backups of all current databases. This can be overridden with custom
# scripting. See the individual files in config/homebin/ for details.
if defined? VagrantPlugins::Triggers