Skip to content

Instantly share code, notes, and snippets.

@axavio
Created July 1, 2012 16:34
Show Gist options
  • Save axavio/3028885 to your computer and use it in GitHub Desktop.
Save axavio/3028885 to your computer and use it in GitHub Desktop.
Dump Single Diaspora User's Stuff
# Handy commands to download a single user's data from a diaspora database by the podmin
#
# These are strictly manual. No attempt is made to make things nice for a production
# environment where these scripts/commands might by run frequently.
#
# Original Source: gist by Pistos for posts and comments
#
# Caveats:
#
# POSTGRESQL ONLY! The psql command may be modified to a mysql command, but the flags/options are likely very different
#
# TESTED ON PISTOS-PODS ONLY! This is intended for use on pods where the diaspora database schema is circa January 2012.
# It does not account for any changes made to the database structure after that point.
#
# Assumes role name is 'diaspora' and db name is 'diaspora_production'.
#
## DUMP COMMENTS
# Set author_id to desired people table record id
echo 'SELECT c.id, c.guid, p.guid AS post_guid, c.created_at, c.text, c.likes_count FROM comments c, posts p WHERE p.id = c.commentable_id AND c.author_id = 3 ORDER BY c.id' | psql -U diaspora -h localhost -A -F '
' -R '
--- record
' diaspora_production > diaspora-comments.dump
## DUMP POSTS
# Set author_id to desired people table record id
echo 'select id, guid, created_at, text, likes_count FROM posts WHERE author_id = 3 order by id' | psql -U diaspora -h localhost -A -F '
' -R '
--- record
' diaspora_production > diaspora-posts.dump
## LIST PHOTOS
# Set author_id to desired people table record id
echo 'SELECT id, guid, status_message_guid, created_at, remote_photo_path || remote_photo_name AS name FROM photos ph WHERE author_id = 3 ORDER BY id' | psql -U diaspora -h localhost -A -F '
' -R '
--- record
' diaspora_production > diaspora-photos.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment