Commit dbe1672f authored by Pietro Albini's avatar Pietro Albini

Merge branch 'scrumb_scripts' of code.ubuntu-it.org:ubuntu-it-web/www-test into scrumb_scripts

parents 38ee677a a0e7d284
......@@ -32,11 +32,14 @@
-- 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");
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');
-- 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 drupal_authmap;
TRUNCATE drupal_cache;
......@@ -72,4 +75,4 @@ TRUNCATE drupal_watchdog;
-- Delete sensitive variables
DELETE FROM drupal_variable WHERE name IN ('drupal_secret_key', 'cron_key');
DELETE FROM drupal_variable WHERE name LIKE 'openid_%';
DELETE FROM drupal_variable WHERE name LIKE 'disqus_%';
\ No newline at end of file
DELETE FROM drupal_variable WHERE name LIKE 'disqus_%';
......@@ -6,6 +6,8 @@
# 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
# 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.
#
......@@ -25,26 +27,24 @@
# 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}
local_db='temp_scrub'
dump_input=${1}
dump_output=${2}
# Destroy previous temp database and create a new one
dropdb --if-exists $local_db
createdb $local_db
dropdb --if-exists "$local_db"
createdb "$local_db"
# Extract the file and import in psql
gunzip -c $dump_input | tar xvf - | psql $local_db
tar -xOvf "$dump_input" | psql "$local_db"
# Scrub the database
psql $local_db < scrub.sql
psql "$local_db" < scrub.sql
# Esport the db
pg_dump $local_db > scrubbed-db.sql
tar -cvzf $dump_output scrubbed-db.sql
# Export the db
pg_dump "$local_db" > scrubbed-db.sql
tar -cvzf "$dump_output" scrubbed-db.sql
# Removed temporary files
dropdb --if-exists $local_db
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