Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
Nuovo sito - PHP
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
37
Issues
37
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gruppo Web
Nuovo sito - PHP
Commits
8ca68635
Commit
8ca68635
authored
Jun 27, 2014
by
Riccardo Padovani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finished the script to scrumb the database
parent
3e243990
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
scrumb.sql
scrumb.sql
+4
-1
sql_scrumb_dump.sh
sql_scrumb_dump.sh
+8
-8
No files found.
scrumb.sql
View file @
8ca68635
...
@@ -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
;
...
...
sql_scrumb_dump.sh
100644 → 100755
View file @
8ca68635
...
@@ -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
< scru
m
b.sql
# E
s
port the db
# E
x
port 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment