Commit 8ca68635 authored by Riccardo Padovani's avatar Riccardo Padovani

Finished the script to scrumb the database

parent 3e243990
...@@ -32,11 +32,14 @@ ...@@ -32,11 +32,14 @@
-- So we truncate the table and insert a new admin user with pass admin -- So we truncate the table and insert a new admin user with pass admin
TRUNCATE drupal_users; TRUNCATE drupal_users;
INSERT INTO drupal_users(uid, name, pass, mail, timezone, language, status, init) INSERT INTO drupal_users(uid, name, pass, mail, timezone, language, status, init)
VALUES (1, "admin", "434c3264048726754ee0e07e508d867e", "admin@localhost", "Europe/Berlin", "it", 1, "admin@localhost"); VALUES (1, 'admin', '434c3264048726754ee0e07e508d867e', 'admin@localhost', 'Europe/Berlin', 'it', 1, 'admin@localhost');
-- Turnoff modules -- Turnoff modules
DELETE FROM drupal_system WHERE name IN ('tweet_button', 'openid_test', 'openid_launchpad', 'openid_teams', 'googleanalytics', 'google_plusone', 'openid', 'fblikebutton', 'disqus'); DELETE FROM drupal_system WHERE name IN ('tweet_button', 'openid_test', 'openid_launchpad', 'openid_teams', 'googleanalytics', 'google_plusone', 'openid', 'fblikebutton', 'disqus');
-- Delete emails from comments
UPDATE drupal_comment SET name='Anonymous', mail='anonymous@localhost', homepage='http://www.ubuntu-it.org' WHERE uid=0;
-- Truncate tables with sensitive data -- Truncate tables with sensitive data
TRUNCATE drupal_cache; TRUNCATE drupal_cache;
TRUNCATE drupal_cache_block; TRUNCATE drupal_cache_block;
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
# You need a file named 'scrub.sql' with querys to scrub the db # 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 # Use as ./sql_scrub_dump.sh dump_file_input.tar.gz dump_file_output.tar.gz
# Of course you need to launch it with a user which has a role to create
# database in Postgresql
# #
# The input and the output dump have to be .tar.gz. # The input and the output dump have to be .tar.gz.
# #
...@@ -25,23 +27,21 @@ ...@@ -25,23 +27,21 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# Some params # Some params
local_db = temp_scrub local_db='temp_scrub'
local_user = ${1} dump_input=${1}
local_pass = ${2} dump_output=${2}
dump_input = ${3}
dump_output = ${4}
# Destroy previous temp database and create a new one # Destroy previous temp database and create a new one
dropdb --if-exists $local_db dropdb --if-exists $local_db
createdb $local_db createdb $local_db
# Extract the file and import in psql # Extract the file and import in psql
gunzip -c $dump_input | tar xvf - | psql $local_db tar -xOvf $dumb_input | psql $local_db
# Scrub the database # Scrub the database
psql $local_db < scrub.sql psql $local_db < scrumb.sql
# Esport the db # Export the db
pg_dump $local_db > scrubbed-db.sql pg_dump $local_db > scrubbed-db.sql
tar -cvzf $dump_output scrubbed-db.sql tar -cvzf $dump_output 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