Commit 3e243990 authored by Riccardo Padovani's avatar Riccardo Padovani

Started to work on files to create a scrumbed dump. Scripts were not tested yet

parent 9f6e5166
-- SQL file to strip out private informations from wwwtest.ubuntu-it.org
-- database that should be not around on developer systems, disable modules
-- that shouldn't be enabled and set admin password to one easy to use for
-- developing purposes
--
-- All our tables have 'drupal' as prepend
--
-- Copyright (C) 2014 Riccardo Padovani <riccardo@rpadovani.com>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- In drupal_authname there are all users authentication names.
-- We use OpenID, so there are only links to OpenID profiles.
-- If classic authentication is used, decomment the following lines
-- UPDATE drupal_authmap SET authname = CONCAT(aid, '@localhost');
-- In drupal_users there are some interesting informations:
-- Anyway, we don't want to use in local same users we use on test server,
-- because we disable OpenID module, otherwise no one could access but
-- ubuntu-it-www members
-- So we truncate the table and insert a new admin user with pass admin
TRUNCATE drupal_users;
INSERT INTO drupal_users(uid, name, pass, mail, timezone, language, status, init)
VALUES (1, "admin", "434c3264048726754ee0e07e508d867e", "admin@localhost", "Europe/Berlin", "it", 1, "admin@localhost");
-- Turnoff modules
DELETE FROM drupal_system WHERE name IN ('tweet_button', 'openid_test', 'openid_launchpad', 'openid_teams', 'googleanalytics', 'google_plusone', 'openid', 'fblikebutton', 'disqus');
-- Truncate tables with sensitive data
TRUNCATE drupal_cache;
TRUNCATE drupal_cache_block;
TRUNCATE drupal_cache_bootstrap;
TRUNCATE drupal_cache_field;
TRUNCATE drupal_cache_filter;
TRUNCATE drupal_cache_form;
TRUNCATE drupal_cache_image;
TRUNCATE drupal_cache_l10n_update;
TRUNCATE drupal_cache_menu;
TRUNCATE drupal_cache_page;
TRUNCATE drupal_cache_panels;
TRUNCATE drupal_cache_path;
TRUNCATE drupal_cache_token;
TRUNCATE drupal_cache_update;
TRUNCATE drupal_cache_views;
TRUNCATE drupal_cache_views_data;
TRUNCATE drupal_disqus;
TRUNCATE drupal_flood;
TRUNCATE drupal_history;
TRUNCATE drupal_openid_association;
TRUNCATE drupal_openid_nonce;
TRUNCATE drupal_openid_teams_roles;
TRUNCATE drupal_openid_teams_trusted;
TRUNCATE drupal_search_dataset;
TRUNCATE drupal_search_index;
TRUNCATE drupal_search_node_links;
TRUNCATE drupal_search_total;
TRUNCATE drupal_sessions;
TRUNCATE drupal_watchdog;
#!/bin/bash
#
# Script to create a scrubbed version of a pgsql 9.x database dump using a temp database
# as intermediary.
#
# You need a file named 'scrub.sql' with querys to scrub the db
#
# Use as ./sql_scrub_dump.sh dump_file_input.tar.gz dump_file_output.tar.gz
#
# The input and the output dump have to be .tar.gz.
#
# Copyright (C) 2014 Riccardo Padovani <riccardo@rpadovani.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Some params
local_db = temp_scrub
local_user = ${1}
local_pass = ${2}
dump_input = ${3}
dump_output = ${4}
# Destroy previous temp database and create a new one
dropdb --if-exists $local_db
createdb $local_db
# Extract the file and import in psql
gunzip -c $dump_input | tar xvf - | psql $local_db
# Scrub the database
psql $local_db < scrub.sql
# Esport the db
pg_dump $local_db > scrubbed-db.sql
tar -cvzf $dump_output scrubbed-db.sql
# Removed temporary files
dropdb --if-exists $local_db
rm -f scrubbed-db.sql
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment