#9617 Deleted Project from pagure
Closed: Fixed 4 years ago by kevin. Opened 4 years ago by x3mboy.

Describe what you would like us to do:

Recover the Project https://pagure.io/i3-sig/Fedora-i3-Spin that I've deleted by mistake. the project is under the group https://pagure.io/group/i3-sig

When do you need this to be done by? (YYYY/MM/DD)

ASAP, we are really close to the deadlines for F34, and I did this mistake.


This is not going to be straight forward as we would have to load the last DB dump and extract from it the information about this project :-/

This is not going to be straight forward as we would have to load the last DB dump and extract from it the information about this project :-/

I know. Just do the best you can do, I trust in the work you do. Thanks for taking this.

Metadata Update from @smooge:
- Issue priority set to: Waiting on Assignee (was: Needs Review)
- Issue tagged with: high-trouble, medium-gain, ops, pagure

4 years ago

@pingou I put in /root/pagure-restore-2021-03-04 on batcave01:

The db dump before the delete
The git repo for the project before the delete.

Can you load that into pagure? or tell me how? ;)

Or perhaps it would be easiest to just remake the project and then sync the git repo in place?

@pingou I put in /root/pagure-restore-2021-03-04 on batcave01:

The db dump before the delete
The git repo for the project before the delete.

Can you load that into pagure? or tell me how? ;)

Or perhaps it would be easiest to just remake the project and then sync the git repo in place?

Or perhaps it would be easiest to just remake the project and then sync the git repo in place?

I think we'll go this way. The big question is what was in the DB, we can't rollback to that version, otherwise all other projects will be affected. I'm thinking, maybe load that dumb into another DB and see if we can somehow re-create what it had

The easy part, the git repo is done.

Fighting the DB

Ok so here is what I did:

  • Create the project manually
  • Update its id so it matches the old one and thus makes importing the old data easier:
    update projects set id=7981 where id=9293;
  • Adjust the parent_id of the forks so it points again to the project
    update projects set parent_id=7981 where is_fork=TRUE and name='Fedora-i3-Spin';
  • Mess up the SQL query above, stop apache and all of its services, rename the DB, import the dump made above (notify a couple of people on #fedora-releng about the mess up as they've managed to comment just between the db dump and the restore)

  • Load the DB dump in a local postgresl db so I could access it easily

  • Export the issues: COPY(select * from issues where project_id=7981) TO STDOUT delimiter '~';
  • Copy the output to /tmp/... on the pagure host
  • Do a DB dump in case
  • Load the issues: COPY issues ( id, uid, project_id, title, content, user_id, assignee_id, status, private, date_created, priority, closed_at, milestone, close_status, last_updated, closed_by_id ) FROM '/tmp/issues2' DELIMITER '~';
  • Export the issue_comments COPY(select * from issue_comments where issue_comments.issue_uid in (select uid from issues where project_id=7981)) TO STDOUT delimiter '~';
  • Copy the output to /tmp/... on the pagure host
  • Do a DB dump in case
  • Load the issue_comments:
    COPY issue_comments ( id, uid, title, project_id, branch, project_id_from, branch_from, commit_start, commit_stop, user_id, assignee_id, date_created, merge_status, status, closed_by_id, remote_git, updated_on, closed_at, initial_comment, last_updated, private, allow_rebase ) FROM '/tmp/prs' DELIMITER '~';
  • Export the pull_requests: COPY(select * from pull_requests where project_id=7981) TO STDOUT delimiter '~';
  • Do a DB dump in case
  • Load the pull_requests:
    COPY pull_requests ( id, uid, title, project_id, branch, project_id_from, branch_from, commit_start, commit_stop, user_id, assignee_id, date_created, merge_status, status, closed_by_id, remote_git, updated_on, closed_at, initial_comment, last_updated, private, allow_rebase ) FROM '/tmp/prs' DELIMITER '~';
  • Export the pull_requests_comments: COPY(select * from pull_request_comments where pull_request_uid in (select uid from pull_requests where project_id=7981)) TO STDOUT delimiter '~';
  • Do a DB dump in case
  • Load the pull_request_comments:
    COPY pull_request_comments ( id, pull_request_uid, commit_id, user_id, filename, line, comment, parent_id, date_created, editor_id, edited_on, notification, tree_id, _reactions ) FROM '/tmp/prs_comments' DELIMITER '~';
  • Export the pull_request_flags: COPY(select * from pull_request_flags where pull_request_uid in (select uid from pull_requests where project_id=7981)) TO STDOUT delimiter '~'; (there were none)

Note: we specify the column in the order they are in the local copy of the DB, order which may differ from the production DB, thus the need to specify them.

So most things should be back. Let us know if I've missed any

Metadata Update from @pingou:
- Issue assigned to pingou

4 years ago

Everything look ok, there is an extra branch, but we can deal with it. I don't know how "Roadmaps" are stored in the database, but that's missing. Let us check it more deeply, at least until the end of the day to close the issue.

Thanks so much, you're amazing!

@pingou Thank you for working on this. Whenever we have Flock again, we owe you a $beverage. :pray:

I tried setting a public notification email address for Pull Requests, but I received a Fatal Error (500). Not sure what happened.

I'm imported the priorities and milestones but looks like the issues aren't showing as assigned to their milestone, sorry :(

@x3mboy anything important still missing?

If not, who should I give the project to? I don't think I need to be the main admin for it :)

No, it's working perfectly, thanks so much. I was the previous owner, so to me, I think.

Also, you can close this. I'm really, really thankful for your help here

Metadata Update from @kevin:
- Issue close_status updated to: Fixed
- Issue status updated to: Closed (was: Open)

4 years ago

The project has been transferred :)

Log in to comment on this ticket.

Metadata
Boards 1
ops Status: Done